Package Modeling :: Package DatabaseAdaptors :: Package PostgresqlAdaptorLayer :: Module PostgresqlSQLExpression :: Class PostgresqlSQLExpression
[show private | hide private]
[frames | no frames]

Type PostgresqlSQLExpression

   object --+    
            |    
SQLExpression --+
                |
               PostgresqlSQLExpression


Sub-class of SQLExpression for the PostgresqlAdaptor. It overrides valueTypeForExternalTypeMapping() to add some new
Method Summary
  columnTypeStringForAttribute(self, attribute)
Overrides default implementation to handle TEXT field properly.
  sqlEscapeChar(self)
Postgresql interprets strings, hence the escape char is a double backslash
  sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar)
Overrides default behaviour so that '%' is changed to '%' instead of '%': postgresql interprets backslashes in strings
  valueTypeForExternalTypeMapping(self)
Adds the following SQL types to the set returned by Modeling.SQLExpression:
    Inherited from SQLExpression
  __init__(self, anEntity)
Initializer
  addBindVariableDictionary(self, binding)
  addCreateClauseForAttribute(self, attribute)
Adds the create clause for the supplied 'attribute' to the receiver's listString.
  addInsertListAttribute(self, attribute, value)
Parameters:
  addJoinClause(self, leftName, rightName, semantic)
  addOrderByAttributeOrdering(self, sortOrdering)
  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:
  aliasesByRelationshipPath(self)
Returns the dictionary of table aliases used by the SQLExpression ; the keys are relationshipPath and the values are the corresponding table aliases.
  allowsNullClauseForConstraint(self, flag)
Returns 'NOT NULL' is flag is false, '' (empty string) otherwise.
  appendItemToListString(self, itemString, aStringIO)
Appends 'itemString' to 'aStringIO' ; if aStringIO is not empty, a comma is appended to aStringIO before 'itemString'
  assembleDeleteStatementWithQualifier(self, aQualifier, tableList, whereClause)
Generates the SQL DELETE statement and assigns it to self's statement() The generated statement has the following format:
  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:
  assembleSelectStatementWithAttributes(self, attributes, lock, qualifier, fetchOrder, selectString, columnList, tableList, whereClause, joinClause, orderByClause, lockClause)
  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:
  bindVariableDictionaries(self)
  bindVariableDictionaryForAttribute(self, attribute, value)
  entity(self)
Returns the Entity bound to that SQLExpression
  entityExternalNamesByAliases(self)
  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.
  joinClauseString(self)
Unimplemented and unused: the joinClause is not used in this implementation of SQLExpression.
  joinExpression(self)
Unimplemented and not used: cf.
  listString(self)
Has a different meaning depending on what the SQLExpression was made for:
  lockClause(self)
  mustUseBindVariableForAttribute(self, attribute)
  orderByString(self)
  prepareConstraintStatementForRelationship(self, relationship, sourceColumns, destinationColumns)
  prepareDeleteExpressionForQualifier(self, aQualifier)
Prepares the internal state to generate a SQL delete statement, according to entity() and parameter 'aQualifier'.
  prepareInsertExpressionWithRow(self, row)
Generates an INSERT statement for the supplied 'row' and the SQLExpression's entity().
  prepareSelectCountExpressionWithAttributes(self, attributes, lock, fetchSpec)
Prepares a 'SELECT' statement from retrieving the number of rows corresponding to the request.
  prepareSelectExpressionWithAttributes(self, attributes, lock, fetchSpec)
Prepares a 'SELECT' statement.
  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.
  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()'
  sqlStringForAttribute(self, attribute)
Returns the attribute's columnName, prepended with the table alias for the empty string if the SQLExpression uses table aliases.
  sqlStringForAttributeNamed(self, name)
Returns the sql string for the attribute 'name'.
  sqlStringForAttributePath(self, path)
Given a path (see below), builds the corresponding sql string, completed with a table alias if the SQLExpression useAliases().
  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.
  sqlStringForConjoinedQualifiers(self, qualifiers)
Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-conjoined'' qualifiers.
  sqlStringForData(self, data)
Not supported yet
  sqlStringForDate(self, aDate)
Formats the 'mxDateTime.DateTime' object 'aDate'.
  sqlStringForDisjoinedQualifiers(self, qualifiers)
Returns the SQL string, to be inserted in a WHERE clause, for the supplied ``to-be-disjoined'' qualifiers.
  sqlStringForInOperatorValue(self, aList, key)
Returns the SQL string suitable for operator IN and NOT IN.
  sqlStringForJoinSemantic(self, joinSemantic)
  sqlStringForKeyComparisonQualifier(self, aQualifier)
Returns the SQL string for the KeyComparisonQualifier supplied.
  sqlStringForKeyValueQualifier(self, aQualifier)
Returns the SQL string for the KeyValueQualifier supplied.
  sqlStringForNegatedQualifier(self, aQualifier)
Returns the SQL string for the supplied Qualifier
  sqlStringForNumber(self, aNumber, keyPath)
Formats 'aNumber' and returns the string suitable for inclusion in a SQL statement.
  sqlStringForQualifier(self, aQualifier)
Returns the SQL WHERE clause string built from 'aQualifier' ; NB: the generated statement does not include the 'WHERE' SQL keyword.
  sqlStringForSchemaObjectName(self, name)
Unimplemented
  sqlStringForSelector(self, selector, value)
Returns the appropriate SQL string corresponding to 'selector'
  sqlStringForString(self, aString)
Formats 'aString' and returns the string suitable for inclusion in a SQL statement.
  sqlStringForValue(self, value, keyPath)
Simply calls formatValueForAttribute() and return the formatted string
  statement(self)
Returns the statement assigned to this object.
  tableListWithRootEntity(self, anEntity)
  toString(self)
Simply returns self.statement()
  useAliases(self)
Returns whether the SQLExpression uses table aliases.
  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.
  valueTypeForExternalType(self, externalTypeName)
Returns the value type corresponding to 'externalTypeName'.
  whereClauseString(self)
Returns the WHERE clause string generated for a given SQL statement.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Class Variable Summary
    Inherited from SQLExpression
int SQL92_join = 1                                                                     

Method Details

columnTypeStringForAttribute(self, attribute)

Overrides default implementation to handle TEXT field properly.

It returns a different string depending on some of the attribute's properties:

  • if attribute's precision is not zero: 'externalType(precision, scale)'
  • if attribute's width is not zero and its externalType is not TEXT: 'externalType(width)'
  • otherwise returns: 'externalType'

About 'TEXT': a model can define a width for a TEXT field. It should be ignored when generating the database schema (for example, TEXT(30) is an invalid data type), however it might be set to request the validation mechanism to check the attribute's length at runtime, typically before an EditingContext saves its changes.

See also:
addCreateClauseForAttribute() SchemaGeneration.createTableStatementsForEntityGroup()
Overrides:
Modeling.SQLExpression.SQLExpression.columnTypeStringForAttribute

sqlEscapeChar(self)

Postgresql interprets strings, hence the escape char is a double backslash
Overrides:
Modeling.SQLExpression.SQLExpression.sqlEscapeChar

sqlPatternFromShellPatternWithEscapeCharacter(self, pattern, escapeChar)

Overrides default behaviour so that '%' is changed to '%' instead of '%': postgresql interprets backslashes in strings
Overrides:
Modeling.SQLExpression.SQLExpression.sqlPatternFromShellPatternWithEscapeCharacter

valueTypeForExternalTypeMapping(self)

Adds the following SQL types to the set returned by Modeling.SQLExpression:

{ 'datetime': DateType,
'timestamp without time zone': DateType, 'timestamp with time zone': DateType, 'text', CharacterType,

}

Quoted from the Postgresql's documentation http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=datatype-datetime.html:

The time type can be specified as time or as time without time zone [...] Writing just 'timestamp' is equivalent to 'timestamp without time zone'. [...] Note: Prior to PostgreSQL 7.3, writing just timestamp was equivalent to timestamp with time zone. This was changed for SQL spec compliance.

(end of quote)

Warning: do NOT use 'datetime' with postgresql-server v7.3 or higher: support for 'datetime' has been dropped in v7.3 ; it is kept here for compatibility with postgresql v7.2.

Overrides:
Modeling.SQLExpression.SQLExpression.valueTypeForExternalTypeMapping

Generated by Epydoc 2.1 on Sat Mar 4 13:36:22 2006 http://epydoc.sf.net