Open mindplay-dk opened 7 years ago
Alternative proposal:
We could introduce some kind of Value
wrapper-type: a kind of boxed value that carries both the colum/type and the value itself - for example:
$user = $schema->user;
$insert = $db->insert($user)
->add([
$user->first_name->value("Rasmus"),
$user->last_name->value("Schultz"),
]);
This way, you wouldn't need to specify column-name as a key - instead, the Column
model has a value()
factory-method that constructs a Value
model, which would have e.g. getName()
and getType()
methods, which could then be used internally in the query-builders.
When building custom INSERT and UPDATE queries, column-references need to be unqualified, which is currently a bit cumbersome - you have to manually unqualify every column-references by explicitly calling
getName()
as in the following:This approach has the undesirable side-effect of also unquoting the column-names.
If we could explicitly request a table-instance that produces quoted, but unqualified column-objects, the above could be simplified as:
This allows us to remove all the
getName()
calls, making this a possible alternative to #35 as well.We may need to distinguish between NULL and
""
in this argument, or provide some other means of explicitly asking for an unqualified table-instance, possibly a factory-method on theTable
class itself.