-
Notifications
You must be signed in to change notification settings - Fork 188
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
options :azure, :contained, and :use_utf16 need to be coerced to boolean from string/nil #461
Comments
Does
Where is the code responsible for this? |
I already started testing a WIP PR for this ... new unit tests first. I was thinking code something like the following (half baked) psuedocode:
the corresponding rails typecasting code is in |
I'm somewhat skeptical that that code should live here in the tiny_tds project. To a reasonable degree, this project should be web framework agnostic and follow normal gem paradigms. Treating Do other database gems do this kind of thing? Should that code live in the activerecord sql server adapter? |
wrote up an issue for |
@aharpervc good point see: rails/rails#9097 (comment) and rails/rails@e54acf1 which explicitly defer type-coercion into the adapter layer -- however, the config option needs to be a config option key that the adapter layer is aware of, and TinyTDS has not explicitly published these newer settings into the sqlserver adapter layer as yet. (actually, from reading the code, and later comments, the type-coercion is deferred to the |
Yeah, I'm thinking that is possible the preferable way to do it. That seems like the piece of the stack that could reasonably be responsible for handling "rails" <-> "database driver" connectivity, which in this case means mapping various properties and their data types |
@aharpervc after looking through the code in the activerecord-sqlserver-adapter, I concur that it should be responsible for the type-casting as it is already reading (aka |
another thought -- usually when I have two (or more) pieces of code that need a shared understanding of data format, I write a schema and then either a code generator from the schema to each user of that data, or write a schema interpreter in each user, and share the schema amongst them. In this particular case, we have at least 3 pieces of code that need a shared understanding of the config attributes --- (1) TinyTDS, (2) AR-SqlServer-Adapter, (3) application code (database.yml), (4) Devops config (env URL). |
see PR here -> rails-sqlserver/activerecord-sqlserver-adapter#741 |
TinyTDS v2.1.2 and current HEAD
Current State:
At the moment, the only "false" values for these configs are "nil" and the boolean value
false
, whereas all non-nil string values, including the empty string and the string "false" are interpreted as the boolean valuetrue
.This presents several issues:
1.1. the config values :azure, :contained, and :use_utf16 are not known to the scaffolding currently provided in rails, and are interpreted as string type.
database.yml
2.1 setting any of the aforementioned options in
database.yml
to any value other than nil can not be converted to a booleanfalse
value by anything set in 'DATABASE_URL', even if 'DATABASE_URL' contains "?azure=false", it will be interpreted by TinyTDS as booleantrue
3.1 Rails ActiveRecord/ActiveModel has type conversions which already set expectations on how strings are converted to a target of boolean, ideally TinyTDS would use the same conversion.
Rails Reference and also Discussion here
Desired State:
false
, consistent with ActiveRecord conversion from database native string to Ruby boolean.The text was updated successfully, but these errors were encountered: