lib/ridgepole/dsl_parser.rb in ridgepole-0.4.8.rc1 vs lib/ridgepole/dsl_parser.rb in ridgepole-0.4.8.rc2
- old
+ new
@@ -1,7 +1,13 @@
class Ridgepole::DSLParser
class Context
+ def self.include_module(mod)
+ unless self.included_modules.include?(mod)
+ include mod
+ end
+ end
+
class TableDefinition
attr_reader :__definition
def initialize
@__definition = {}
@@ -139,17 +145,22 @@
end
def parse(dsl, opts = {})
definition, execute = Context.eval(dsl, opts)
check_orphan_index(definition)
+
+ if @options[:enable_foreigner]
+ Ridgepole::ForeignKey.check_orphan_foreign_key(definition)
+ end
+
[definition, execute]
end
private
def check_orphan_index(definition)
definition.each do |table_name, attrs|
- if attrs.length == 1 and attrs[:indices]
+ if attrs[:indices] and not attrs[:definition]
raise "Table `#{table_name}` to create the index is not defined: #{attrs[:indices].keys.join(',')}"
end
end
end
end