thekid/rfc — Issue #124: RFC 0124 use sql functions in restrictions:
Author: thekid
Created: 2011-10-09 15:15:25+00:00
State: open
Labels: implemented, rfc

Scope of Change
====
- Extend the criteria api to use SQL standard functions in
a query
- common function interface for all databases

Rationale
====
- One wants to use SQL functions, like date functions, in a criteria query
- Because of database predefined functions are not standardized,
different databases provide different signatures for the same function
- To render the functions for differen dialects the class rdbms.DBConnctions
needs to extedet by the method rdbms.DBConnctions::getFormatter()
- The rdbms.StatementFormatter needs to know two new tokens
- %e is a datatype identifier
- %u is a datepart identifier

Functionality
====

```
To use functions the package rdbms.SQLFunctions has to be imported.

```

usage
----
- Functions can be created with the static rdbms.SQLFunctions factory
SQLFunctions::acos(0.125);

- Functions can be nested
SQLFunctions::acos(SQLFunctions::cos(0.125));

- functions can be either used as a projection part or a restriction's value
Criteria::newInstance()->setProjection(SQLFunctions::rand());
Criteria::newInstance()->add(Restrictions::equal("texture_id", SQLFunctions::ceil(0.3)));

Security considerations
====
n/a

Speed impact
====
May be slows the criteria rendering process

Dependencies
====
- RFC 0123
http://xp-framework.net/rfc/0123.rfc.html
- RFC 0126
http://xp-framework.net/rfc/0126.rfc.html
- added the parameter of type SQLDialect tothe rdbms.StatementFormatter's constructor

Related documents
====
- xp-lab
http://experiments.xp-framework.net/?people,wagner,rfc,0123
http://experiments.xp-framework.net/?people,wagner,rfc,0124
http://experiments.xp-framework.net/?people,wagner,rfc,0126
- Joint patch for RFC0096, RFC0123, RFC0124 and RFC0129 against skeleton
http://xp-framework.net/rfc/contrib/rfc0096_0123_0124_0129/skeleton.diff
- Joint patch for RFC0096, RFC0123, RFC0124 and RFC0129 against ports
http://xp-framework.net/rfc/contrib/rfc0096_0123_0124_0129/ports.diff

Comments
====