<Michiel Meeuwissen:>
> 
> Actually, I have once (must be about a year ago) started to
> implement this (as a excercise for search-query, and to 
> perhaps use it). I never really used it though, and was not 
> sure if REGEXP should indeed be a FieldCompareConstraint.
> 
> I could check-in my progress (still lingering here) and test
> it (in mysql and posgresql) a bit, to grant the wish.
> 
> But I think at least Rob must agree (because it is his code),
> and perhaps it would even require a VOTE.
> 
> Kees submitted the wish, I'm not sure why he wants to use
> regexps, and which database he uses. 
> 
> So, I'd like some feed-back, about this.

Extending the query framework with new constraint-type is quite
straightforward:
 
1 - Define a new interface, subclassing an appropriate existing
Constraint interface (FieldConstraint in this case).
Do not add methods to the existing interfaces, since these represent
constrainttypes that are supported by all SQL databases.
StringSearchConstraint provides an example of a non-standard
constrainttype.

2 - Create a basic implementation for this interface.

3 - Adjust the SqlHandler for the supporting databases (e.g.
MySqlSqlHandler, PostgreSqlSqlHandler) to support the constrainttype. 
By default SqlHandler implementations do not support new
constrainttypes.

Regarding databases not supporting the constraint: I strongly recommend
not to provide a fallback implementation in cases like this. 
The performance drawback and lack of precision using code to emulate the
functionality will inevitably make this approach virtually useless. The
framework provides methods to test whether a constraint is supported,
this can be used to provide different strategies based on what is
supported.

Depending on whether you're developing for a specific database setup,
your options are to either develop for a specific setup or to develop
for all databases, using different strategies based on what is
supported.

Rob van Maris
Technical Consultant

Quantiq
xmedia & communication solutions

Koninginneweg 11-13
1217 KP Hilversum
 
T    +31 (0)356257211
M    +31 (0)651444006
E    [EMAIL PROTECTED]
W   http://www.quantiq.com


Reply via email to