user1883212 user1883212 - 3 months ago 48
YAML Question

MoSql and YAML parsing: Invalid ordered hash entry

I'm using MoSql 0.4.3 with the following YAML file:

MyDb:
Names:
:meta:
:table: Names
:extra_proprs: true
:columns:
- _id: INTEGER
- Name:
:source: Name
:type: TEXT


However I receive the following error:

ERROR MoSQL: Error parsing collection map `test.yaml':
ERROR MoSQL: Invalid ordered hash entry {"Name"=>{:source=>"Name", :type=>"TEXT"}}


Yet I followed the documentation. How can I fix it?

Documentation:

https://github.com/stripe/mosql/pull/37/files?diff=split

Answer

Your YAML input has errors. The key :source cannot have the same indentation as the sequence element indicator -, it has to align with the first key in the mapping Name (and so does :type):

MyDb:
  Names:
    :meta:
      :table: Names
      :extra_proprs: true
    :columns:
     - _id: INTEGER
     - Name:
       :source: Name
       :type: TEXT

just like in the documentation example the key :source is aligned with `author_name'.

Comments