-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow functions to be default values (#252)
* docs: add examples for acceptance test * fix: allow functions to be default values * ci: Fix emulator version to 1.5.0 Because newer Spanner emulators have a bug aroud information schema. They cannot return correct values for COLUMN_DEFAULT. spanner> SELECT COLUMN_NAME, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME="dynamic_items"; +---------------+--------------------+ | COLUMN_NAME | COLUMN_DEFAULT | +---------------+--------------------+ | id | NULL | | col_timestamp | CURRENT_TIMESTAMP( | +---------------+--------------------+ 2 rows in set (2.079298ms) * build: use latest emulator version now that the related bug is fixed * chore: added missing 'the' * ci: add AR v7.0.5 to nightly tests --------- Co-authored-by: nownabe <nownabe@users.noreply.github.com> Co-authored-by: Knut Olav Løite <koloite@gmail.com>
- Loading branch information
1 parent
ecf3ea4
commit f651bbf
Showing
5 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
require "test_helpers/with_separate_database" | ||
|
||
module Models | ||
class DefaultValueTest < SpannerAdapter::TestCase | ||
include TestHelpers::WithSeparateDatabase | ||
|
||
class DynamicItem < ActiveRecord::Base; end | ||
|
||
def test_dynamic_default_values | ||
connection.create_table :dynamic_items do |t| | ||
t.column :col_timestamp, :datetime, default: -> { "CURRENT_TIMESTAMP()" } | ||
end | ||
|
||
item = DynamicItem.create! | ||
item.reload | ||
assert(item.col_timestamp) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters