Skip to content

Commit

Permalink
Fix SRID SQL syntax for database version compatibility in schema crea…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
jeff.dean committed Mar 4, 2025
1 parent a570b71 commit 53a3136
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ class SchemaCreation < MySQL::SchemaCreation # :nodoc:

def add_column_options!(sql, options)
if options[:srid]
sql << " /*!80003 SRID #{options[:srid]} */"
sql << if @conn.database_version >= "8.0.0"
" SRID #{options[:srid]} "
else
" /*!50705 SRID #{options[:srid]} */ "
end
end

super
Expand Down
2 changes: 1 addition & 1 deletion test/ddl_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_create_geometry_using_shortcut_with_srid
col = klass.columns.last
assert_equal RGeo::Feature::Geometry, col.geometric_type
if klass.connection.supports_index_sort_order?
assert_equal({ srid: 4326, type: "geometry" }, col.limit)
assert_equal({ type: "geometry", srid: 4326 }, col.limit)
else
assert_equal({ srid: 0, type: "geometry" }, col.limit)
end
Expand Down

0 comments on commit 53a3136

Please sign in to comment.