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

Migrations are now creating int8 fields as char in the DB and then the value gets messed up when querying #165

Open
raphaelcruzeiro opened this issue Sep 23, 2020 · 1 comment

Comments

@raphaelcruzeiro
Copy link

I was testing some code on my local machine using a project that is actually deployed to production and works fine there when I noticed that querying one of my models which had int8 fields (all of which have values that can vary between 0 and 7) the resulting Swift object had wildly incorrect values like 49, 50, 51, etc. As querying using my sql client returned me the correct values, it took me a while to notice that the same migration that had created the fields as int4 in production a few months ago was now creating these fields as char. So my local database had the "correct" char as in '1' but whatever the postgres driver is doing when quering it, it was effectivelly messing up the conversion back to int in Swift ('1' became 49, etc).

Version

2.1.0

Steps to reproduce:

  • Create a model with an Int8 field and map it to an int8 field on the migration.
  • Run the migration (Field is created as char on the DB)
  • Instantiate a new object of that model and set the field to 1
  • Save it
  • Fetch the same object with a query. Field will now be set to 49
@abear247
Copy link

abear247 commented Jan 1, 2023

We are also experiencing this issue. Any hope for a fix?

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

2 participants