midgardproject / midgard-core

The base library of the Midgard Content Repository
http://midgard-project.org/docs/
Other
37 stars 6 forks source link

Query constraints don't follow `field` definitions from MgdSchema #49

Closed bergie closed 13 years ago

bergie commented 13 years ago

In MgdSchema there is a way to specify a different database column to be used than name of the property. This is useful when using SQL reserved words for property names (see #47).

Example:

<property name="to" type="guid" parentfield="to" field="objectguid" />

Then doing a query with QB:

$qb->add_constraint('to', '=', 'b04ce874fdf311df9b1aa33ae9d312201220');
$qb->execute();

Causes a "Invalid query" error.

Same thing happens with QuerySelect.

feri commented 13 years ago

We ran into the "SQL reserved words" problem (#47) when using midgard_query_select.

The php code is:

$q = new midgard_query_select($storage);
$relations = $q->execute();

The error in midgard2.log is:

  midgard-core (pid:3074):(WARNING):Execute error - near "from": syntax error

And the referring property in mgdschema is

<property name="from" type="unsigned integer" link="com_meego_package:id" parentfield="from" field="frompackage" />
piotras commented 13 years ago

Fixed.