Charta Software
Back to the base
E-mail:
Wachtwoord:
Aangemaakt door op 2009-06-03 13:42:06
Laatst gewijzigd op 2010-03-15 10:26:31

Implemented TSQLExpression.Copy

Function TSQLExpression.Copy now has been implemented. The addition of this function has some implications that I will describe here.

The function TSQLExpression.Copy has been added to support the automatic manipulation of SQL queries. Automatic SQL manipulation is used for query optimization, enforcing authorization restrictions and adding versioning capabilities. By using the Copy function of an SQL expression one can obtain a copy of the expression that can be changed without the risk of changing the original query.

This change means that every TSQLExpression descendant should correctly implement the Copy function by making a copy of all its relevant members. If an error is made in a copy function this will certainly affect the correctness of queries. Currently all the relevant SQL expressions have an implementation of the copy function. However, everyone should be alert that some errors might have crept in. So be sure to test your query results and if some old functionality suddenly is broken you know where to look.

When adding new SQL expressions yourself you now also should properly implement the copy function and, more importantly, if you change an existing expression you should check whether the copy function still copies all relevant parts correctly.

As you can see in the current implementations of the copy function, typically every base class has its own specific copy function which is called from TSQLExpression.Copy. For instance, TSQLOperator.Copy calls TSQLOperator.CopyOperator. This pattern helps making copy functions type safe when you want to copy a specific descendant.