Class: Sequel::Extension::PgComment::PrefixSqlGenerator
- Inherits:
-
SqlGenerator
- Object
- SqlGenerator
- Sequel::Extension::PgComment::PrefixSqlGenerator
- Defined in:
- lib/sequel/extensions/pg_comment/sql_generator.rb
Overview
:nodoc: This is an annoying corner-case generator -- it doesn't handle any types by default, but it will handle any other type where the name of a table needs to be prefixed by a name. The only known use case for this at present is "implicit" (that is, automatically generated by the database) constraints and indexes that get prefixed by the table name, and which are generated at a time when the calling code doesn't know the name of the table that it is generating SQL for.
Constant Summary collapse
- OBJECT_TYPES =
This class doesn't handle any object types directly, and must be instantiated directly when needed
%w{}
Instance Attribute Summary collapse
-
#table_name ⇒ Object
The name of the table which should be prefixed to the object name that was specified when this instance was created.
Attributes inherited from SqlGenerator
#comment, #object_name, #object_type
Instance Method Summary collapse
-
#generate ⇒ Object
Generate super-dooper special SQL.
Methods inherited from SqlGenerator
Constructor Details
This class inherits a constructor from Sequel::Extension::PgComment::SqlGenerator
Instance Attribute Details
#table_name ⇒ Object
The name of the table which should be prefixed to the object name that was specified when this instance was created.
233 234 235 |
# File 'lib/sequel/extensions/pg_comment/sql_generator.rb', line 233 def table_name @table_name end |
Instance Method Details
#generate ⇒ Object
Generate super-dooper special SQL.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/sequel/extensions/pg_comment/sql_generator.rb', line 239 def generate if table_name.nil? raise ArgumentError, "Cannot generate SQL for #{object_type} #{object_name} " + "without a table_name" end prefixed_object_name = "#{table_name}#{object_name}" if Symbol === table_name || Symbol === object_name prefixed_object_name = prefixed_object_name.to_sym end g = SqlGenerator.create(object_type, prefixed_object_name, comment) g.table_name = table_name if g.respond_to? :table_name g.generate end |