Skip to content

Type conversions

Vlad edited this page Nov 27, 2017 · 15 revisions

Yaml and SQL(and different SQL dialects, of course) have slightly different system of types and it means that some of YML types could not be easily converted to SQL "as is" or "one to one".

Strings

Strings will be implicitly converted to SQL string literals and formatted depending on the selected SQL dialect. For SQL99, for instance, the string value will be surrounded with single quotes: Hello in YAML turns into 'Hello' in SQL.

Not supported types

Following YAML types are not supported by JFixtures at the moment and an exception will be thrown if they occur:

We plan to support these types in the future, at least partially and for some SQL dialects, but for now, please use plain SQL values to express complicated and non trivial SQL types.

Plain SQL values

As it was described above, string values will be converted to SQL string literals("Homer" turns to 'Homer'), but what if we need to write a SQL expression itself as a value? There is sql: prefix for these purposes: sql:DEFAULT turns to DEFAULT, sql:NOW() turns to NOW() and so on.

What if you want a string SQL literal with 'sql' value? Another trick - write text:sql in yaml. Combining sql: and text: prefixes it is possible to write any string literal or plain SQL expression in the destination SQL.

Clone this wiki locally