Ensure the SQLite3 adapter handles default functions with the || concatenation operator#49287
Conversation
4aa6140 to
40ab8c4
Compare
|
Thank you for opening a pull request. |
Hey @yahonda, thanks for taking the time to review. To be perfectly honest, the primary reason that I opened this PR was because a Rails test schema for PostgreSQL used Here is a quick GitHub search I ran to find some instances of There is some noise in the results, but you will see a number of usages, which all indeed are joining some dynamic values. I presume that the joining of all static strings was used in the tests for simplicity. |
|
can you rebase this? |
40ab8c4 to
f1104e6
Compare
@guilleiguaran: Done |
…ncatenation operator
Previously, this default function would produce the static string `"'Ruby ' || 'on ' || 'Rails'"`.
Now, the adapter will appropriately receive and use `"Ruby on Rails"`.
```ruby
change_column_default "test_models", "ruby_on_rails", -> { "('Ruby ' || 'on ' || 'Rails')" }
```
f1104e6 to
828eec6
Compare
Previously, this default function would produce the static string
"'Ruby ' || 'on ' || 'Rails'". Now, the adapter will appropriately receive and use"Ruby on Rails".Motivation / Background
The wave of using SQLite in production is growing, but the ActiveRecord
SQLite3Adapterdoesn't take full advantage of the power and functionality of the SQLite engine. In order to begin making theSQLite3Adapterfeature-comparable with theMySQLAdapterandPostgreSQLAdapter, I am undertaking a multi-step task to level up theSQLite3Adapter.Detail
I am beginning with the simplest improvement I initially found, in order to "get my feet wet" with the process of upstreaming feature to Rails and ActiveRecord. Instead of using the
CONCAT()function, SQLite provides the||concatenation operator. The adapter does not recognize usage of this operator as a dynamicdefault_function, however.Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]