diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-18 20:24:52 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-18 21:57:48 +0100 |
| commit | 62123e577ee5d4066d53f8ad7e5ac3d2eb190430 (patch) | |
| tree | f569686630681a9eceb2685f69b55fe5a2bac17c /lib/model/tests/identifier.t | |
| parent | 7087a0c2c84e796e474784cbd28d4a4e574cf2c0 (diff) | |
Securized the queries in the database with a dedicated type for the Identifiers
Diffstat (limited to 'lib/model/tests/identifier.t')
| -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] |
