Refactor _type_cast & _quote.
#534
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I made a mistake and made
_type_castdo quoting too. This is now fixed and we have greatly simplified it along with_quoteand we now use these two to cast and quote as needed in our sp_executesql helpers.Changed
sp_executesql_sql_typeto have a defaultStringcase tonvarchar(max)not ideal and there are places where we prefer the bind contain the proper SQLServer type. For example, uniquness validations yielding aActiveRecord::Relation::QueryAttributewith a basic cast type vs the in scopecast_typefurther up.Added
sp_executesql_sql_paramwhich looks out for allSQLServer::Dataand quotes it accordingly. For example, date & time objects need single quote '' vs. national N'' quoting.SQLServer::Datashared for all types. Delegates quoting decisoin back to type.cc @sgrif