Home | Trees | Index | Help |
|
---|
Package Modeling :: Module SQLExpression :: Class SQLExpression |
|
object
--+
|
SQLExpression
MySQLSQLExpression
,
OracleSQLExpression
,
PostgresqlSQLExpression
,
SQLiteSQLExpression
Method Summary | |
---|---|
Initializer | |
addBindVariableDictionary(self,
binding)
| |
Adds the create clause for the supplied 'attribute' to the receiver's listString. | |
Parameters: | |
addJoinClause(self,
leftName,
rightName,
semantic)
| |
addOrderByAttributeOrdering(self,
sortOrdering)
| |
Adds the sqlStringForAttributeNamed(attribute.name()) to the SQLExpression's listString(). | |
Uses appendItemToListString() to add to listString() a string formatted that way: | |
Returns the dictionary of table aliases used by the SQLExpression ; the keys are relationshipPath and the values are the corresponding table aliases. | |
Returns 'NOT NULL' is flag is false, '' (empty string) otherwise. | |
Appends 'itemString' to 'aStringIO' ; if aStringIO is not empty, a comma is appended to aStringIO before 'itemString' | |
Generates the SQL DELETE statement and assigns it to self's statement() The generated statement has the following format: | |
Generates the SQL INSERT statement and assigns it to self's statement() The generated statement has the following format: | |
assembleSelectStatementWithAttributes(self,
attributes,
lock,
qualifier,
fetchOrder,
selectString,
columnList,
tableList,
whereClause,
joinClause,
orderByClause,
lockClause)
| |
Generates the SQL INSERT statement and assigns it to self's statement() The generated statement has the following format: | |
bindVariableDictionaries(self)
| |
bindVariableDictionaryForAttribute(self,
attribute,
value)
| |
Returns the string corresponding to the attribute's column type definition when creating a table. | |
Returns the Entity bound to that SQLExpression | |
entityExternalNamesByAliases(self)
| |
Unimplemented | |
Unimplemented | |
Unimplemented | |
Examines the attribute's externalType and forwards the request to the appropriate method. | |
Unimplemented and unused: the joinClause is not used in this implementation of SQLExpression. | |
Unimplemented and not used: cf. | |
Has a different meaning depending on what the SQLExpression was made for: | |
lockClause(self)
| |
mustUseBindVariableForAttribute(self,
attribute)
| |
orderByString(self)
| |
prepareConstraintStatementForRelationship(self,
relationship,
sourceColumns,
destinationColumns)
| |
Prepares the internal state to generate a SQL delete statement, according to entity() and parameter 'aQualifier'. | |
Generates an INSERT statement for the supplied 'row' and the SQLExpression's entity(). | |
Prepares a 'SELECT' statement from retrieving the number of rows corresponding to the request. | |
Prepares a 'SELECT' statement. | |
Parameters: | |
Sets the object's SQL statement. | |
Tells the SQLExpression whether it should use table aliases. | |
Bind variables are not supported yet | |
Bind variables are not supported yet | |
sqlEscapeChar(self)
| |
Simply calls sqlPatternFromShellPatternWithEscapeCharacter() with 'escapeChar' equal to 'self.sqlEscapeChar()' | |
Transforms the shell 'pattern', using '*' and '?' as wildcards (the former matches 0 to many characters while the second matches one character) to an valid SQL pattern. | |
Returns the attribute's columnName, prepended with the table alias for the empty string if the SQLExpression uses table aliases. | |
Returns the sql string for the attribute 'name'. | |
Given a path (see below), builds the corresponding sql string, completed with a table alias if the SQLExpression useAliases(). | |
Returns the SQL string, to be inserted in a WHERE clause, for case-insensitive comparison between a lvalue and a rvalue. | |
Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-conjoined'' qualifiers. | |
Not supported yet | |
Formats the 'mxDateTime.DateTime' object 'aDate'. | |
Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-disjoined'' qualifiers. | |
Returns the SQL string suitable for operator IN and NOT IN. | |
sqlStringForJoinSemantic(self,
joinSemantic)
| |
Returns the SQL string for the KeyComparisonQualifier supplied. | |
Returns the SQL string for the KeyValueQualifier supplied. | |
Returns the SQL string for the supplied Qualifier | |
Formats 'aNumber' and returns the string suitable for inclusion in a SQL statement. | |
Returns the SQL WHERE clause string built from 'aQualifier' ; NB: the generated statement does not include the 'WHERE' SQL keyword. | |
Unimplemented | |
Returns the appropriate SQL string corresponding to 'selector' | |
Formats 'aString' and returns the string suitable for inclusion in a SQL statement. | |
Simply calls formatValueForAttribute() and return the formatted string | |
Returns the statement assigned to this object. | |
tableListWithRootEntity(self,
anEntity)
| |
Simply returns self.statement() | |
Returns whether the SQLExpression uses table aliases. | |
Bind variables are not supported yet: return '0' (false) | |
This is set when prepareInsertExpressionWithRow() is called, and it holds the list of values to insert. | |
Returns the value type corresponding to 'externalTypeName'. | |
Returns a dictionary consisting of the valid SQL types, each of which being a key bound to either 'BinaryType', 'CharacterType', 'DateType' or 'NumericType' (module's constants) | |
Returns the WHERE clause string generated for a given SQL statement. | |
Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
T.__new__(S, ...) -> a new object with type S, a subtype of T | |
helper for pickle | |
helper for pickle | |
x.__repr__() <==> repr(x) | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) |
Class Variable Summary | |
---|---|
classobj |
Internals = Modeling.SQLExpression.Internals |
int |
SQL92_join = 1 |
Method Details |
---|
__init__(self,
anEntity=None)
Initializer |
addCreateClauseForAttribute(self, attribute)Adds the create clause for the supplied 'attribute' to the receiver's listString. The default implementation appends a line of the following form: <newline><COLUMN_NAME> <COLUMN_TYPE_STRING> <ALLOWS_NULL_CLAUSE> where <COLUMN_NAME> is the attribute's columnName(), <COLUMN_TYPE_STRING> is 'columnTypeStringForAttribute(attribute)' and <ALLOWS_NULL_CLAUSE> is 'allowsNullClauseForConstraint(attribute.allowsNull())'.
|
addInsertListAttribute(self, attribute, value)Parameters:
|
addSelectListAttribute(self, attribute)Adds the sqlStringForAttributeNamed(attribute.name()) to the SQLExpression's listString().
|
addUpdateListAttribute(self, attribute, value)Uses appendItemToListString() to add to listString() a string formatted that way: <attribute's columnName()> = <value> See also: prepareUpdateExpressionWithRow(), listString() |
aliasesByRelationshipPath(self)Returns the dictionary of table aliases used by the SQLExpression ; the keys are relationshipPath and the values are the corresponding table aliases. If useAliases() is true, the dictionary contains at least one entry with an empty string as the key and 't0' being the corresponding value. Otherwise, it may be None. That dictionary is built upon successive invocation of sqlStringForAttributePath().
|
allowsNullClauseForConstraint(self, flag)Returns 'NOT NULL' is flag is false, '' (empty string) otherwise. Subclasses should override this method, without calling it, if the underlying database uses a different syntax for such a clause. See: addCreateClauseForAttribute() |
appendItemToListString(self, itemString, aStringIO)Appends 'itemString' to 'aStringIO' ; if aStringIO is not empty, a comma is appended to aStringIO before 'itemString' Parameters:
|
assembleDeleteStatementWithQualifier(self, aQualifier, tableList, whereClause)Generates the SQL DELETE statement and assigns it to self's statement() The generated statement has the following format: DELETE FROM <tableList> WHERE <whereClause> Parameters:
See also: statement(), prepareDeleteExpressionForQualifier() |
assembleInsertStatementWithRow(self, row, tableList, columnList, valueList)Generates the SQL INSERT statement and assigns it to self's statement() The generated statement has the following format: INSERT INTO <tableList> [<columnList>] VALUES <valueList> <columnList> will be omitted Parameters:
See also: statement(), prepareInsertExpressionWithRow() |
assembleUpdateStatementWithRow(self, row, aQualifier, tableList, updateList, whereClause)Generates the SQL INSERT statement and assigns it to self's statement() The generated statement has the following format: UPDATE <tableList> SET <updateList> WHERE <whereClause> Parameters:
See also: statement(), prepareUpdateExpressionWithRow() |
columnTypeStringForAttribute(self, attribute)Returns the string corresponding to the attribute's column type definition when creating a table. Default implementation returns a different string depending on some of the attribute's properties:
Subclasses should override this method, without calling it, if the underlying database uses a different syntax for column types.
|
entity(self)Returns the Entity bound to that SQLExpression See: __init__() |
externalNameQuoteCharacter(self)Unimplemented |
formatSQLString(self, sqlString, format)Unimplemented |
formatStringValue(self, string)Unimplemented |
formatValueForAttribute(self, value, attribute)Examines the attribute's externalType and forwards the request to the appropriate method. The methods to which the message is forwarded are:
Raises InvalidSQLTypeError is the attribute's external type is unknown for the concrete adaptor. See also: valueTypeForExternalType(), sqlStringForValue() |
joinClauseString(self)Unimplemented and unused: the joinClause is not used in this implementation of SQLExpression. The statements necessary to support joins (for SELECT, mainly) are generated in the whereClause when the tables and their aliases are examined. |
joinExpression(self)Unimplemented and not used: cf. joinClauseString() |
listString(self)Has a different meaning depending on what the SQLExpression was made for:
statement (in: 'UPDATE ... SET ... WHERE ...') |
prepareDeleteExpressionForQualifier(self, aQualifier)Prepares the internal state to generate a SQL delete statement, according to entity() and parameter 'aQualifier'. The process is the following:
See also: assembleDeleteStatementWithQualifier(), whereClauseString() |
prepareInsertExpressionWithRow(self, row)Generates an INSERT statement for the supplied 'row' and the SQLExpression's entity(). The process is the following:
The generated INSERT statement is then available through 'statement()' Parameter:
|
prepareSelectCountExpressionWithAttributes(self, attributes, lock, fetchSpec)Prepares a 'SELECT' statement from retrieving the number of rows corresponding to the request. The statement is then available as a string in self.statement(). See also: AdaptorChannel.rowCountForSelectAttributes() |
prepareSelectExpressionWithAttributes(self, attributes, lock, fetchSpec)Prepares a 'SELECT' statement. The statement is then available as a string in self.statement(). See also: AdaptorChannel.selectAttributes() |
prepareUpdateExpressionWithRow(self, row, aQualifier)Parameters:
|
setStatement(self, statement)Sets the object's SQL statement. |
setUseAliases(self, useAliases)Tells the SQLExpression whether it should use table aliases. This method has a side-effect: if flag 'useAliases' is true and the SQLExpression's aliasesByRelationshipPath() is empty, the latter gets value 't0' for key '""' (empty string) ; if the flag is false, aliasesByRelationshipPath() is reset. See also: useAliases() |
setUseBindVariables(self, flag)Bind variables are not supported yet |
shouldUseBindVariableForAttribute(self, attribute)Bind variables are not supported yet |
sqlPatternFromShellPattern(self, pattern)Simply calls sqlPatternFromShellPatternWithEscapeCharacter() with 'escapeChar' equal to 'self.sqlEscapeChar()' |
sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar)Transforms the shell 'pattern', using '*' and '?' as wildcards (the former matches 0 to many characters while the second matches one character) to an valid SQL pattern.
|
sqlStringForAttribute(self, attribute)Returns the attribute's columnName, prepended with the table alias for the empty string if the SQLExpression uses table aliases. For example, the returned value for an attribute 'title' whose columnName is 'TITLE' is 'TITLE', or 't0.TITLE' if useAliases() is true. See also: useAliases(), aliasesByRelationshipPath(), Attribute.columnName() |
sqlStringForAttributeNamed(self, name)Returns the sql string for the attribute 'name'. If the corresponding attribute is a regular Attribute (non flattened), it triggers sqlStringForAttribute() ; otherwise, it builds the path and triggers sqlStringForAttributePath() (see sqlStringForAttributePath() for a description of what 'building the path' means). Raises ValueError in case 'name' is not a valid attribute's name.
|
sqlStringForAttributePath(self, path)Given a path (see below), builds the corresponding sql string, completed with a table alias if the SQLExpression useAliases(). Parameter 'path' is a list composed of Relationship objects that has to be traversed to access the final Attribute, which is the last element of the list. If table aliases is on and aliasesByRelationshipPath() has no key corresponding to the relationshipPath, that key is set with a new table alias. Example: say we have two entities 'Book' and 'Writer', a toOne relationship 'toBook' from 'Writer' to 'Book', and 'Writer' defined an attribute 'bookTitle' flattening 'toBook.title' (title being a regular attribute of 'Book'). When table aliases is on, this methods returns something like 't1.TITLE' --in that case, aliasesByRelationshipPath() has a key 'toBook' corresponding to the value 't1'. Important note: It seems that derived attribute should not be used except to support inheritance and the vertical-mapping approach. This is not supported for the moment being, thus this method is desactivated and will unconditionnally raise when invoked. See the project's TODO file for a more complete explanation.
|
sqlStringForCaseInsensitiveLike(self, keyString, valueString)Returns the SQL string, to be inserted in a WHERE clause, for case-insensitive comparison between a lvalue and a rvalue. Default implementation returns the following string: UPPER(<keyString>) LIKE UPPER(<valueString>) Parameters:
|
sqlStringForConjoinedQualifiers(self, qualifiers)Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-conjoined'' qualifiers. Default implementation returns: <qualifierString1> AND <qualifierString2> AND ... ... AND <qualifierString_i> where '<qualifierString_i>' is 'sqlStringForQualifier(qualifiers[i])' Parameter:
See also: sqlStringForQualifier() |
sqlStringForData(self, data)Not supported yet |
sqlStringForDate(self, aDate)Formats the 'mxDateTime.DateTime' object 'aDate'. SQLExpression's implementation simply returns 'str(aDate)', or 'NULL' if 'aDate' is None. See also: formatValueForAttribute() |
sqlStringForDisjoinedQualifiers(self, qualifiers)Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-disjoined'' qualifiers. Default implementation returns: <qualifierString1> OR <qualifierString2> OR ... OR <qualifierString_i> where '<qualifierString_i>' is 'sqlStringForQualifier(qualifiers[i])' Parameter:
See also: sqlStringForQualifier() |
sqlStringForInOperatorValue(self, aList, key)Returns the SQL string suitable for operator IN and NOT IN. The returned string is a comma-separated list of the values in aList, surrounded by brackets.
|
sqlStringForKeyComparisonQualifier(self, aQualifier)Returns the SQL string for the KeyComparisonQualifier supplied. It is of the form: <left_columnName> <operator> <right_columnName> such as in: t0.LAST_NAME != t2.FIRST_NAME Both column names are returned by sqlStringForAttributeNamed(), and the operator is computed by sqlStringForSelector(). When the quelifier's operator is Qualifier.QualifierOperatorCaseInsensitiveLike, the returned string is calculated by sqlStringForCaseInsensitiveLike. Parameter: aQualifier -- a Qualifier.KeyComparisonQualifier instance See also: sqlStringForQualifier() |
sqlStringForKeyValueQualifier(self, aQualifier)Returns the SQL string for the KeyValueQualifier supplied. It is of the form: <key> <operator> <value> such as in: t0.LAST_NAME LIKE 'R%' 'key' is returned by sqlStringForAttributeNamed(), 'operator', by sqlStringForSelector(), and 'value': by sqlStringForValue(), or by sqlPatternFromShellPattern() is the qualifier's operator is 'LIKE' or case-insensitive-LIKE (and, when the case-insensitive form of 'LIKE' is used, the returned string is computed by sqlStringForCaseInsensitiveLike) Parameter: aQualifier -- a Qualifier.KeyValueQualifier instance See also: sqlStringForQualifier() |
sqlStringForNegatedQualifier(self, aQualifier)Returns the SQL string for the supplied Qualifier The string returned is: NOT (<qualification>) where 'qualification' is 'sqlStringForQualifier(aQualifier)' Parameter:
|
sqlStringForNumber(self, aNumber, keyPath='')Formats 'aNumber' and returns the string suitable for inclusion in a SQL statement. SQLExpression's implementation simply returns 'str(aNumber)', or 'NULL' if 'aDate' is None. See also: formatValueForAttribute() |
sqlStringForQualifier(self, aQualifier)Returns the SQL WHERE clause string built from 'aQualifier' ; NB: the generated statement does not include the 'WHERE' SQL keyword. Default implementation delegates the actual generation of the SQL string to the appropriate method [sqlStringFor...Qualifier()], depending on aQualifier's type/class. Note that this method does not set the whereClauseString() ; it is the responsability for the caller to set it when appropriate.
|
sqlStringForSchemaObjectName(self, name)Unimplemented |
sqlStringForSelector(self, selector, value)Returns the appropriate SQL string corresponding to 'selector' Parameters:
Depending on 'operator', the returned value is:
Raise 'ValueError' if 'selector' is not in that list. Note that 'QualifierOperatorCaseInsensitiveLike' is not in the list: this is intended. Specific transformations for this operator are handled by the specific methods sqlStringForKeyValueQualifier(), etc. See also: sqlStringForKeyValueQualifier() and others related methods |
sqlStringForString(self, aString)Formats 'aString' and returns the string suitable for inclusion in a SQL statement. SQLExpression's implementation surrounds the string with simple quotes, and back-quotes any simple quotes 'aString' may have. It returns 'NULL' if 'aString' is None. See also: formatValueForAttribute() |
sqlStringForValue(self, value, keyPath)Simply calls formatValueForAttribute() and return the formatted string Implementation note: when SQL bind variable are supported this should update the bindings dictionary and return the name of the bind variable. |
statement(self)Returns the statement assigned to this object. The statement could have been set either with 'setStatement()' or by any of the following methods:
|
toString(self)Simply returns self.statement() |
useAliases(self)Returns whether the SQLExpression uses table aliases. See also: setUseAliases() |
useBindVariables(self)Bind variables are not supported yet: return '0' (false) |
valueList(self)This is set when prepareInsertExpressionWithRow() is called, and it holds the list of values to insert. Returned value is a string, such as: "12, 'Hugo', 'Victor', NULL" See also: listString(), prepareInsertExpressionWithRow() |
valueTypeForExternalType(self, externalTypeName)Returns the value type corresponding to 'externalTypeName'. The correspondance table is the following:
Returns None when no corresponding value type can be found. Parameter:
See also: formatValueForAttribute(), valueTypeForExternalTypeMapping() |
valueTypeForExternalTypeMapping(self)Returns a dictionary consisting of the valid SQL types, each of which being a key bound to either 'BinaryType', 'CharacterType', 'DateType' or 'NumericType' (module's constants) Important: the SQL types should be lower-cased Default implementation returns: { 'char': CharacterType, 'float': NumericType, 'int': NumericType, 'integer': NumericType, 'numeric': NumericType, 'date': DateType, 'time': DateType, 'timestamp': DateType, 'varchar': CharacterType, } See also: valueTypeForExternalType() |
whereClauseString(self)Returns the WHERE clause string generated for a given SQL statement. This is set by: prepareInsertExpressionWithRow(), prepareSelectExpressionWithAttributes() |
Class Variable Details |
---|
SQL92_join
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Sat Mar 4 13:36:27 2006 | http://epydoc.sf.net |