Skip to content

Commit

Permalink
Set SQL_AUTO_IS_NULL=0 by default when connecting to MySQL via the jd…
Browse files Browse the repository at this point in the history
…bc adapter
  • Loading branch information
jeremyevans committed May 19, 2011
1 parent 73a8fea commit 710ce88
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,5 +1,7 @@
=== HEAD

* Set SQL_AUTO_IS_NULL=0 by default when connecting to MySQL via the swift and jdbc adapters (jeremyevans)

* Fix bug in multiple column IN/NOT IN emulation when a model dataset is used (jeremyevans)

* Add support for filtering and excluding by association datasets (jeremyevans)
Expand Down
9 changes: 9 additions & 0 deletions lib/sequel/adapters/jdbc/mysql.rb
Expand Up @@ -56,6 +56,15 @@ def requires_return_generated_keys?
def schema_column_type(db_type)
db_type == 'tinyint(1)' ? :boolean : super
end

# By default, MySQL 'where id is null' selects the last inserted id.
# Turn that off unless explicitly enabled.
def setup_connection(conn)
super
sql = "SET SQL_AUTO_IS_NULL=0"
log_yield(sql){conn.execute(sql)} unless opts[:auto_is_null]
conn
end
end

# Dataset class for MySQL datasets accessed via JDBC.
Expand Down
1 change: 1 addition & 0 deletions lib/sequel/adapters/swift/mysql.rb
Expand Up @@ -29,6 +29,7 @@ def schema_column_type(db_type)
# By default, MySQL 'where id is null' selects the last inserted id.
# Turn that off unless explicitly enabled.
def setup_connection(conn)
super
sql = "SET SQL_AUTO_IS_NULL=0"
log_yield(sql){conn.execute(sql)} unless opts[:auto_is_null]
conn
Expand Down

0 comments on commit 710ce88

Please sign in to comment.