Open benmerckx opened 6 years ago
Currently there's no way to create a primary key on multiple columns.
Well, you can put @:primary
on several columns. But yes, the order is determined by the field order.
But I am afraid you can't put meta on typedef
, iirc.
Well, you can put @:primary on several columns.
Completely missed that, thanks!
But I am afraid you can't put meta on typedef, iirc.
Looks like that has been changed: http://try-haxe.mrcdk.com/#17276
You can put meta on typedefs, but it's a bit tricky to pick it up (you have to follow the type one by one).
Ok, ignore that. Turns out I have dealt with this before: https://github.com/haxetink/tink_macro/blob/master/src/tink/macro/Types.hx#L52 :D
As for the naming, we can exploit the call syntax like what we did in tink_unittest:
@:index('index_name'(field1, field2))
Currently there's no way to create a primary key on multiple columns. Also the order of fields in an index are important, but right now the order is defined by how the fields are ordered in the definition. In spod they were defined on the table, instead of on the fields, like this:
@:index(field1, field2)
. That takes care of ordering, but doesn't allow you to name the index. It's more verbose but I think something like this might be more suitable (name could be optional):Having the current metadata as shortcuts on fields could still be allowed, but it requires some checks to make sure you're not overwriting other indexes. If we do change the behaviour it's probably also best to not keeps these in the columns, but seperately as an array on a
Table
instance. The data types could then also be merged with what I have currently defined inSchema
: