diff options
Diffstat (limited to 'lib/model/tests')
| -rw-r--r-- | lib/model/tests/identifier.t | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/model/tests/identifier.t b/lib/model/tests/identifier.t new file mode 100644 index 0000000..39460ff --- /dev/null +++ b/lib/model/tests/identifier.t @@ -0,0 +1,38 @@ +Test the [Model.Identifier] module: validation of the names, their quoted SQL +form, the predefined columns and the composite names used for the dedicated +tables of multivalued fields. + +Valid identifiers are printed in their quoted SQL form: + + $ tests --identifier check entity user-details user_type_list + "entity" + "user-details" + "user_type_list" + +Invalid identifiers are rejected: the empty string, and any character outside +letters, digits, underscore and hyphen — in particular the double quote (which +could break out of a quoted identifier) and the dot (reserved for the composite +table names): + + $ tests --identifier check 'evil"; DROP TABLE entity;--' foo.bar '' + invalid: "evil"; DROP TABLE entity;--" + invalid: "foo.bar" + invalid: "" + +The fixed columns of the generated schema are predefined: + + $ tests --identifier predefined + id = "id" + parent = "parent" + target = "target" + +A composite name is built from two valid identifiers: + + $ tests --identifier dot entity references + "entity.references" + +An invalid part is rejected when building a composite name: + + $ tests --identifier dot 'bad"name' ref + Fatal error: exception Model.Identifier.Invalid("bad\"name") + [2] |
