Skip to content

Fix foreignkey default#10

Open
vabshere wants to merge 35 commits intomisterEggroll:masterfrom
skit-ai:fix-foreignkey-default
Open

Fix foreignkey default#10
vabshere wants to merge 35 commits intomisterEggroll:masterfrom
skit-ai:fix-foreignkey-default

Conversation

@vabshere
Copy link

Make sure these boxes checked before submitting your pull request.

  • Do only one thing
  • No API-breaking changes
  • New code/logic commented & tested

For significant changes like big bug fixes, new features, please open an issue to make an agreement on an implementation design/plan first before starting it.

What did this pull request do?

Gorm uses the default value for uint, ie 0, in prepared statements while insertion if no foreign key is provided for a model. Doing so requires a primary key with value 0 to be present in the referenced table which is often not the case giving rise to errors.

This PR replaces this 0 with NULL, which should be the actual behaviour.

akshaydeshraj and others added 30 commits August 16, 2019 16:17
add: Fn to remove constraint from a table
…limit

add: Fn to determine dialect-specific byte insertion limit
* If records go beyond 1000000, the ID returned by the oracle driver is of type float64 instead of uint(uint64)
* To mitigate this issue, introducing the `primary` struct
* The `primary` struct implements the `Scanner` interface to convert float64 and int64 into a unit ID
* The `primary` struct implements the `Valuer` interface to return the uint value of the ID it encapsulates
* Introducing the `ORM` struct which makes use of the `primary` struct to encapsulate the ID returned by the DB
* This is to mitigate the scenario where the reference to the rowid of the oracle entry is returned as an int64.
* This int64 is converted to uint internally by the Scan() implementation of the `primary` struct
* Hence, we need to access that converted value by checking if the primary field is of type `primary`
refactor: Export `Primary` struct outside gorm package
refactor: Remove primary key and foreign key custom structs
refactor: Use primaryField.Field.Uint to get uint when resolving row ID
feat: add support for setting nullable
feat: add ModifyColumn support in oci8 dialect
* Setting a new instance `gorm:increment_attrs` which will be leveraged in the update callback code
* Added a switch in the update callback code making use of the `gorm:increment_attrs` instance to modify the SQL accordingly
add: Method to increment integer attrs for a table's row
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

Successfully merging this pull request may close these issues.

4 participants