-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Foreign key property transformation processes undefined value upon save #9565
Comments
I started debugging this. The most interesting things during the This line: typeorm/src/metadata/ColumnMetadata.ts Lines 785 to 786 in dbc1b2e
is called when:
When you step into typeorm/src/metadata/RelationMetadata.ts Line 479 in dbc1b2e
where:
So the expression So back to typeorm/src/metadata/ColumnMetadata.ts Lines 805 to 807 in dbc1b2e
where:
Obviously Then this line is called typeorm/src/metadata/ColumnMetadata.ts Line 816 in dbc1b2e
and this value is returned several lines later. But because I don't know whether this itself is a bug or is it only a part of the whole insert operation that is supposed to work like this, but I have a feeling that this might be the root cause |
I believe that checking if the column is an object literal is the culprit for this bug. If it wasn't for the
in line {797} of I am not sure if the transformation step is going to kick in later or does it also requires some more changes. |
Issue Description
Expected Behavior
Newly created entity containing a foreign key id property (of a custom object type) is properly transformed and then inserted to the database.
Actual Behavior
Foreign key is ignored on some stage of the insert, resulting in an error during transformation of the property/foreign key value:
Steps to Reproduce
I prepared a dedicated repository for this issue:
https://github.com/akwodkiewicz/typeorm-bug-report
README should explain how to use the repository to reproduce the error.
Nonetheless, below I'm pasting the trimmed version of the files used in this repository, so that this bug report does not need to rely on my repository in the future.
Id classes
Entities
Faulty save
My Environment
Additional Context
The error does not happen when the foreign keys and entity ids are typed as primitive
string
s.I'm using sqlite driver, did not try to test it on other drivers.
Also, if you create the
Post
by specifyingauthor: user
instead ofauthorId: USER_ID
then the insert is successful.Relevant Database Driver(s)
aurora-mysql
aurora-postgres
better-sqlite3
cockroachdb
cordova
expo
mongodb
mysql
nativescript
oracle
postgres
react-native
sap
spanner
sqlite
sqlite-abstract
sqljs
sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: