Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

specify $keyType = 'string' if keytype is not int #307

Open
wivaku opened this issue Dec 22, 2024 · 0 comments
Open

specify $keyType = 'string' if keytype is not int #307

wivaku opened this issue Dec 22, 2024 · 0 comments

Comments

@wivaku
Copy link

wivaku commented Dec 22, 2024

[Similar to #233 , but more generic]

If the primary key is not int it should be explicitly defined.
The explicit keytype is needed because Eloquent queries will otherwise assume the key is int.

For tables where the primary key is not integer, set:
public $keyType = 'string';

It already sets the following:
public $incrementing = false;

$body .= $this->class->field('incrementing', false, ['visibility' => 'public']);

It already detects if the primary key is not int:

public function hasCustomPrimaryKeyCast()

It detects the keytype, but not sure if we can / need to use that value.
I believe it can always be set to string if the primary key is not int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant