method

check_constraints

Importance_0
v7.1.3.4 - Show latest stable - 0 notes - Class: SchemaStatements
check_constraints(table_name) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb, line 83
        def check_constraints(table_name)
          table_sql = query_value(            SELECT sql            FROM sqlite_master            WHERE name = #{quote(table_name)} AND type = 'table'            UNION ALL            SELECT sql            FROM sqlite_temp_master            WHERE name = #{quote(table_name)} AND type = 'table', "SCHEMA")

          table_sql.to_s.scan(/CONSTRAINT\s+(?<name>\w+)\s+CHECK\s+\((?<expression>(:?[^()]|\(\g<expression>\))+)\)/).map do |name, expression|
            CheckConstraintDefinition.new(table_name, expression, name: name)
          end
        end
Register or log in to add new notes.