Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Quote names when checking if a constraint exists
[#1427 state:resolved]
  • Loading branch information
solnic committed Mar 9, 2011
1 parent 8caa473 commit 605d3cd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/dm-constraints/adapters/dm-do-adapter.rb
Expand Up @@ -19,11 +19,11 @@ module DataObjectsAdapter
def constraint_exists?(storage_name, constraint_name)
statement = DataMapper::Ext::String.compress_lines(<<-SQL)
SELECT COUNT(*)
FROM "information_schema"."table_constraints"
WHERE "constraint_type" = 'FOREIGN KEY'
AND "table_schema" = ?
AND "table_name" = ?
AND "constraint_name" = ?
FROM #{quote_name('information_schema')}.#{quote_name('table_constraints')}
WHERE #{quote_name('constraint_type')} = 'FOREIGN KEY'
AND #{quote_name('table_schema')} = ?
AND #{quote_name('table_name')} = ?
AND #{quote_name('constraint_name')} = ?
SQL

select(statement, schema_name, storage_name, constraint_name).first > 0
Expand Down

0 comments on commit 605d3cd

Please sign in to comment.