-
Notifications
You must be signed in to change notification settings - Fork 48
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
each method provides column values as strings rather than as their proper type #2
Comments
Please read documentation/README. |
I think this issue should be closed. cc: @afair |
I'd have to check (and I'm on the move now) but surely the underlying driver provide you bytes representing integers so you are serialising into a string somewhere which is presumably more costly than working with or as close to the native data type. I don't know about dates and so on. I'm not suggesting you return model values just that you honour the databases type system. This happens in most other database libraries I'm aware of. |
I have reviewed code of postgresql_cursor but I don't see there any casting. I assume that it's a cause of the |
Yes, My approach here has been to let |
I've looked into this, pg's There doesn't seem to be any functionality in the pg driver to do this for you (possible explained by this: http://wiki.postgresql.org/wiki/Driver_development#Type_Conversions) so it sounds like it might be too much heavy lifting for you to do in your layer. |
I'm closing this as described above. I studied the current ActiveRecord code, and think that using instances instead of rows is best for people who need Ruby types instead of strings. Also, The PostgreSQL binary protocol doesn't transmit the data in Ruby types, and things like Fixnum and DateTime still need to be instantiated, and that's what AR (ActiveRecord) does anyway. However, the current AR only performs these translations as needed and caches them to minimize the cost of instantiation. Because of that, I feel AR's work is really better than anything we can do here. Chasing the constantly changing inner working of AR is tough enough! I have refactored the code in a v0.5 branch/release which I kept this issue in mind while working in it. I hope it works well for you. |
For example when using .each_row dates and integers are returned as strings in a hash. Also dynamic methods do not work, i.e. user.name does not work, but user[:name] does.
The text was updated successfully, but these errors were encountered: