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

Add STI support to hash-based model initializer #426

Merged
merged 1 commit into from Oct 31, 2022

Conversation

imdrasil
Copy link
Owner

@imdrasil imdrasil commented Oct 31, 2022

What does this PR do?

Besides fixing STI model initializing using hash constructor this PR also adds extra layer of database column value coercing. This means that when a result set is read as a hash based on the received data types specification from the database model adapter is used to coerce them based on the attribute desired type.

Fix #403

Release notes

Model

  • add missing STI initialization to constructors accepting a hash or named tuple
  • use Adapter::Base.coerce_database_value in constructors accepting a hash or named tuple to coerce values for columns that don't have specified converter

Adapter

  • add Base.coerce_database_value method to provide interface to perform coercing from default database type used to read column to hash to a desired model attribute type

@imdrasil imdrasil force-pushed the add-adapter-column-value-coercing-layer branch from a0ff7cb to f532938 Compare October 31, 2022 11:10
@imdrasil imdrasil force-pushed the add-adapter-column-value-coercing-layer branch from f532938 to 43ff9ae Compare October 31, 2022 11:17
@imdrasil imdrasil merged commit b04b4b1 into master Oct 31, 2022
@imdrasil imdrasil deleted the add-adapter-column-value-coercing-layer branch October 31, 2022 11:28
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.

Eager loading causes DataTypeCasting exception on sqlite
1 participant