Fix insert() TypeError when primary key is typed as int#34
Closed
enlivenapp wants to merge 1 commit intoflightphp:masterfrom
Closed
Fix insert() TypeError when primary key is typed as int#34enlivenapp wants to merge 1 commit intoflightphp:masterfrom
enlivenapp wants to merge 1 commit intoflightphp:masterfrom
Conversation
lastInsertId() returns a string, which throws a TypeError when assigned to a typed public int property under strict_types. Cast the value to int when the primary key property has an int type declaration. enlivenapp <mw@enlivenapp.com>
Contributor
Author
|
Closed, too much separation. see #33 . Sorry for the noise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I created a subclass with
public int $idand inserted a new record:I expected the insert to succeed and
$user->idto be set to the new auto-increment value.Instead, it throws
TypeError: Cannot assign string to property User::$id of type int, becauselastInsertId()returns a string.Subclasses without a typed primary key are not affected.
Tests included. All existing tests continue to pass.