Skip to content

Commit

Permalink
Update geometry schema dump tests for database version compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff.dean committed Mar 4, 2025
1 parent 4b4b303 commit 15a23f2
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions test/tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ def test_basic_geometry_schema_dump
ActiveRecord::SchemaDumper.dump(connection, file)
end
data = File.read(tmp_sql_filename)
assert_includes data, "t.geometry \"object1\", limit: {type: \"geometry\", srid: #{connection.default_srid}"
assert_includes data, "t.geometry \"object2\", limit: {type: \"geometry\", srid: #{connection.default_srid}"
if connection.database_version >= "8.0.0"
assert_includes data, "t.geometry \"object1\", limit: {type: \"geometry\", srid: #{connection.default_srid}"
assert_includes data, "t.geometry \"object2\", limit: {type: \"geometry\", srid: #{connection.default_srid}"
else
assert_includes data, "t.geometry \"object1\", limit: {:type=>\"geometry\", :srid=>#{connection.default_srid}"
assert_includes data, "t.geometry \"object2\", limit: {:type=>\"geometry\", :srid=>#{connection.default_srid}"
end
end

def test_basic_geography_schema_dump
Expand All @@ -72,13 +77,24 @@ def test_basic_geography_schema_dump
ActiveRecord::SchemaDumper.dump(connection, file)
end
data = File.read(tmp_sql_filename)
assert_includes data, %(t.geometry "latlon1", limit: {type: "point", srid: 0})
if connection.supports_index_sort_order?
assert_includes(data,
%(t.geometry "latlon2", limit: {type: "point", srid: 4326}))
if connection.database_version >= "8.0.0"
assert_includes data, %(t.geometry "latlon1", limit: {type: "point", srid: 0})
if connection.supports_index_sort_order?
assert_includes(data,
%(t.geometry "latlon2", limit: {type: "point", srid: 4326}))
else
assert_includes(data,
%(t.geometry "latlon2", limit: {type: "point", srid: 0}))
end
else
assert_includes(data,
%(t.geometry "latlon2", limit: {type: "point", srid: 0}))
assert_includes data, %(t.geometry "latlon1", limit: {:type=>"point", :srid=>0})
if connection.supports_index_sort_order?
assert_includes(data,
%(t.geometry "latlon2", limit: {:type=>"point", :srid=>4326}))
else
assert_includes(data,
%(t.geometry "latlon2", limit: {:type=>"point", :srid=>0}))
end
end
end

Expand Down

0 comments on commit 15a23f2

Please sign in to comment.