Skip to content

Commit a3bc3d5

Browse files
committed
fix(test): coerced value for generate column
1 parent 9cf2556 commit a3bc3d5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
1+
require "support/copy_cat"
2+
13
exclude :test_build_fixture_sql, "Skipping because CockroachDB cannot write directly to computed columns."
24
exclude :test_schema_dumping, "Replaced with local version"
5+
6+
# From: "ASCII(name)"
7+
# To: "ASCII(name)""::string"
8+
CopyCat.copy_methods(self, self, :test_change_table_without_stored_option) do
9+
def on_str(node)
10+
return unless node in [:str, "ASCII(name)"]
11+
12+
insert_after(node.loc.expression, '"::string"')
13+
end
14+
end

test/support/copy_cat.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def warn(message, category: nil, **kwargs)
2121
# Copy methods from The original rails class to our adapter.
2222
# While copying, we can rewrite the source code of the method using
2323
# ast. Use `debug: true` to lead you through that process.
24+
#
25+
# Once debug is set, you can check the closest node you want to edit
26+
# and then create a method `on_<node_type>` to handle it.
2427
def copy_methods(new_klass, old_klass, *methods, debug: false, &block)
2528
methods.each do |met|
2629
file, _ = old_klass.instance_method(met).source_location

0 commit comments

Comments
 (0)