Inherits from: NSObject
Conforms to: NSObject
(NSObject)
Declared in: EOAccess/EOSQLExpression.h
EOAccess/EOSchemaGeneration.h
EOAccess/EOSchemaSynchronization.h
EOSQLExpression is an abstract superclass that defines how to build SQL statements for adaptor channels. You don't typically use instances of EOSQLExpression; rather, you use EOSQLExpression subclasses written to work with a particular RDBMS and corresponding adaptor. A concrete subclass of EOSQLExpression overrides many of its methods in terms of the query language syntax for its specific RDBMS. EOSQLExpression objects are used internally by the Framework, and unless you're creating a concrete adaptor, you won't ordinarily need to interact with EOSQLExpression objects yourself. You most commonly create and use an EOSQLExpression object when you want to send an SQL statement directly to the server. In this case, you simply create an expression with the EOSQLExpression class method expressionForString:, and send the expression object to an adaptor channel using EOAdaptorChannel's evaluateExpression: method.
For more information on using EOSQLExpressions, see the following sections:
In EOSQLExpression.h, EOSchemaGeneration.h, and EOSchemaSynchronization.h, EOAccess defines the following NSString constants.
Constant | Description |
EOBindVariableNameKey | The key for the name of a bind variable in a bind variable dictionary. |
EOBindVariablePlaceHolderKey | A key for use in bind variable dictionaries. The corresponding value is the placeholder string to be used in SQL. |
EOBindVariableAttributeKey | A key for use in bind variable dictionaries. The corresponding value is the attribute that uses the bind variable. |
EOBindVariableValueKey | A key for use in bind variable dictionaries. The corresponding value is the value for the bind variable. |
EOCreateTablesKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to create tables. |
EODropTablesKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to drop tables. |
EOCreatePrimaryKeySupportKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to create primary key support. |
EODropPrimaryKeySupportKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to drop primary key support. |
EOPrimaryKeyConstraintsKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to create primary key constraints. |
EOForeignKeyConstraintsKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to create foreign key constraints. |
EOCreateDatabaseKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to create a database. |
EODropDatabaseKey | Key for use in options dictionaries. A corresponding value of "YES" indicates that the EOSQLExpression should generate SQL to drop a database. |
EOAllowsNullKey | Key for use in change dictionaries. A corresponding value indicates that the column's allows NULL value should be changed from. |
EOColumnNameKey | Key for use in change dictionaries. A corresponding value indicates that the column's allows NULL value should be changed from. |
EOExternalNameKey | Key for use in change dictionaries. A corresponding value indicates that the column's allows NULL value should be changed from. |
EOExternalTypeKey | Key for use in change dictionaries. A corresponding value indicates that the column's allows NULL value should be changed from. |
EONameKey | Key for use in change dictionaries. A corresponding value indicates the old value of the table or column. |
EOPrecisionKey | Key for use in change dictionaries. A corresponding value indicates the value a column's precision should be changed from. |
EORelationshipsKey | Key for use in change dictionaries. The corresponding value is a dictionary of relationships which have been modified since the last time the model and schema were sychronized. For more information see "The Change Dictionary" . |
EOScaleKey | Key for use in change dictionaries. A corresponding value indicates the value the column's scale should be changed from. |
EOWidthKey | Key for use in change dictionaries. A corresponding value indicates the value the column's width should be changed from. |
- Creating an EOSQLExpression object
- + selectStatementForAttributes:lock:fetchSpecification:entity:
- + insertStatementForRow:entity:
- + updateStatementForRow:qualifier:entity:
- + deleteStatementWithQualifier:entity:
- + expressionForString:
- - initWithEntity:
- Building SQL Expressions
- - prepareSelectExpressionWithAttributes:lock:fetchSpecification:
- - prepareInsertExpressionWithRow:
- - prepareUpdateExpressionWithRow:qualifier:
- - prepareDeleteExpressionForQualifier:
- - setStatement:
- - statement
- Generating SQL for attributes and values
- + formatSQLString:format:
- + formatValue:forAttribute:
- + formatStringValue:
- - sqlStringForValue:attributeNamed:
- - sqlStringForAttributeNamed:
- - sqlStringForAttribute:
- - sqlStringForAttributePath:
- Generating SQL for names of database objects
- - sqlStringForSchemaObjectName:
- + setUseQuotedExternalNames:
- + useQuotedExternalNames
- - externalNameQuoteCharacter
- Generating an attribute list
- - addSelectListAttribute:
- - addInsertListAttribute:value:
- - addUpdateListAttribute:value:
- - appendItem:toListString:
- - listString
- Generating a value list
- - addInsertListAttribute:value:
- - addUpdateListAttribute:value:
- - valueList
- Generating a table list
- - tableListWithRootEntity:
- - aliasesByRelationshipPath
- Generating the join clause
- - joinExpression
- - addJoinClauseWithLeftName:rightName:joinSemantic:
- - assembleJoinClauseWithLeftName:rightName:joinSemantic:
- - joinClauseString
- Generating a search pattern
- + sqlPatternFromShellPattern:
- + sqlPatternFromShellPattern:withEscapeCharacter:
- Generating a relational operator
- - sqlStringForSelector:value:
- Accessing the where clause
- - whereClauseString
- Generating an order by clause
- - addOrderByAttributeOrdering:
- - orderByString
- Accessing the lock clause
- - lockClause
- Assembling a statement
- - assembleSelectStatementWithAttributes:lock:qualifier:fetchOrder:selectString:columnList:tableList:whereClause:joinClause:orderByClause:lockClause:
- - assembleInsertStatementWithRow:tableList:columnList:valueList:
- - assembleUpdateStatementWithRow:qualifier:tableList:updateList:whereClause:
- - assembleDeleteStatementWithQualifier:tableList:whereClause:
- Generating SQL for qualifiers
- - sqlStringForConjoinedQualifiers:
- - sqlStringForDisjoinedQualifiers:
- - sqlStringForKeyComparisonQualifier:
- - sqlStringForKeyValueQualifier:
- - sqlStringForNegatedQualifier:
- Managing bind variables
- + setUseBindVariables:
- + useBindVariables
- - addBindVariableDictionary:
- - bindVariableDictionaries
- - bindVariableDictionaryForAttribute:value:
- - mustUseBindVariableForAttribute:
- - shouldUseBindVariableForAttribute:
- Using table aliases
- - setUseAliases:
- - useAliases
- Accessing the entity
- - entity
- Creating a schema generation script
- + schemaCreationScriptForEntities:options:
- + schemaCreationStatementsForEntities:options:
- + appendExpression:toScript:
- + createTableStatementsForEntityGroup:
- + createTableStatementsForEntityGroups:
- + dropTableStatementsForEntityGroup:
- + dropTableStatementsForEntityGroups:
- + primaryKeyConstraintStatementsForEntityGroup:
- + primaryKeyConstraintStatementsForEntityGroups:
- + primaryKeySupportStatementsForEntityGroup:
- + primaryKeySupportStatementsForEntityGroups:
- + dropPrimaryKeySupportStatementsForEntityGroup:
- + dropPrimaryKeySupportStatementsForEntityGroups:
- - addCreateClauseForAttribute:
- - columnTypeStringForAttribute:
- - allowsNullClauseForConstraint:
- + foreignKeyConstraintStatementsForRelationship:
- - prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:
- - createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:
- - dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:
- Synchronizing the database with a model
- + statementsToUpdateObjectStoreForModel:withChangeDictionary:options:
- + statementsToUpdateObjectStoreForEntityGroup:withChangeDictionary:options:
- + statementsToCopyTableNamed:intoTableForEntityGroup:withChangeDictionary:options:
- + phraseCastingColumnNamed:fromType:toType:options:
- + statementsToRenameTableNamed:newName:options:
- + statementsToInsertColumnForAttribute:options:
- + statementsToDeleteColumnNamed:inTableNamed:options:
- + statementsToRenameColumnNamed:inTableNamed:newName:options:
- + statementsToModifyColumnNamed:inTableNamed:toNullRule:
- + statementsToConvertColumnNamed:inTableNamed:fromType:toType:options:
- + isColumnType:equivalentToColumnType:options:
- + statementsToDropForeignKeyConstraintsOnEntityGroup:withChangeDictionary:options:
- + statementsToDropPrimaryKeyConstraintsOnEntityGroup:withChangeDictionary:options:
- + statementsToDropPrimaryKeySupportForEntityGroup:withChangeDictionary:options:
- + statementsToImplementForeignKeyConstraintsOnEntityGroup:withChangeDictionary:options:
- + statementsToImplementPrimaryKeyConstraintsOnEntityGroup:withChangeDictionary:options:
- + statementsToImplementPrimaryKeySupportForEntityGroup:withChangeDictionary:options:
- Querying about database synchronization support
- + supportsSchemaSynchronization
- + supportsDirectColumnCoercion
- + supportsDirectColumnDeletion
- + supportsDirectColumnInsertion
- + supportsDirectColumnNullRuleModification
- + supportsDirectColumnRenaming
+ (void)appendExpression:(EOSQLExpression
*)anSQLExpression
toScript:(NSMutableString *)script
See Also: + createTableStatementsForEntityGroup:
+ (NSArray *)createDatabaseStatementsForConnectionDictionary:(NSDictionary
*)connectionDictionary
administrativeConnectionDictionary:(NSDictionary
*)adminDictionary
See Also: + dropDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:
+ (NSArray *)createTableStatementsForEntityGroup:(NSArray
*)entityGroup
EOSQLExpression's implementation does the following:
The following is an example of a CREATE TABLE statement produced by the default implementation:
create table EMPLOYEE ( EMP_ID int not null, DEPT_ID int null, LAST_NAME varchar(40) not null, PHONE char(12) null, HIRE_DATE date null, SALARY number(7, 2) null )
If a subclass's database server's table creation semantics are different, the subclass should override this method or one or more of the following methods as appropriate:
See Also: + createTableStatementsForEntityGroup:, + dropTableStatementsForEntityGroup:
+ (NSArray *)createTableStatementsForEntityGroups:(NSArray
*)entityGroups
See Also: + schemaCreationStatementsForEntities:options:
+ (EOSQLExpression *)deleteStatementWithQualifier:(EOQualifier
*)qualifier
entity:(id)entity
NSInvalidArgumentException
if
qualifier is nil.The expression created with this method does
not use table aliases because Enterprise Objects Framework assumes
that all INSERT, UPDATE, and DELETE statements are single-table
operations. As a result, all keys in qualifier should
be simple key names; no key paths are allowed. To generate DELETE
statements that do use table aliases, you must override prepareDeleteExpressionForQualifier: to
send a setUseAliases:YES
message
prior to invoking super
's version.
+ (NSArray *)dropDatabaseStatementsForConnectionDictionary:(NSDictionary
*)connectionDictionary
administrativeConnectionDictionary:(NSDictionary
*)adminDictionary
See Also: + createDatabaseStatementsForConnectionDictionary:administrativeConnectionDictionary:
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroup:(NSArray
*)entityGroup
EOSQLExpression's implementation creates a statement of the following form:
drop sequence SEQUENCE_NAME
Where SEQUENCE_NAME is the primaryKeyRootName: for the first entity in entityGroup concatenated with "_SEQ" (EMP_ID_SEQ, for example).
If a subclass uses a different primary key generation mechanism or if the subclass's database server's drop semantics are different, the subclass should override this method.
+ (NSArray *)dropPrimaryKeySupportStatementsForEntityGroups:(NSArray
*)entityGroups
See Also: + schemaCreationStatementsForEntities:options:
+ (NSArray *)dropTableStatementsForEntityGroup:(NSArray
*)entityGroup
EOSQLExpression's implementation creates a statement of the following form:
DROP TABLE TABLE_NAME
Where TABLE_NAME is the externalName of the first entity in entityGroup.
If a subclass's database server's drop semantics are different, the subclass should override this method.
+ (NSArray *)dropTableStatementsForEntityGroups:(NSArray
*)entityGroups
See Also: + schemaCreationStatementsForEntities:options:
+ (EOSQLExpression *)expressionForString:(NSString
*)string
See Also: - setStatement:
+ (NSArray *)foreignKeyConstraintStatementsForRelationship:(EORelationship
*)aRelationship
ALTER TABLE EMPLOYEE ADD CONSTRAINT TO_DEPARTMENT FOREIGN KEY (DEPT_ID) REFERENCES DEPARTMENT(DEPT_ID)
It returns an empty array if either of the following are true:
If neither of the above are true, this method creates a new EOSQLExpression, assigns its entity to aRelationship's entity, invokes prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:, and returns an array containing the expression.
If a subclass's database server's foreign key constraint semantics are different, the subclass should override this method or override the method prepareConstraintStatementForRelationship:sourceColumns:destinationColumns:.
See Also: + schemaCreationStatementsForEntities:options:
+ (NSString *)formatSQLString:(NSString
*)sqlString
format:(NSString *)format
See Also: - readFormat (EOAttribute), - writeFormat (EOAttribute)
+ (NSString *)formatStringValue:(NSString
*)string
NSInternalInconsistencyException
if string is nil.+ (NSString *)formatValue:(id)value
forAttribute:(EOAttribute *)attribute
+ (EOSQLExpression *)insertStatementForRow:(NSDictionary
*)row
entity:(EOEntity *)entity
NSInvalidArgumentException
if
entity is nil.The expression created with this method does
not use table aliases because Enterprise Objects Framework assumes
that all INSERT, UPDATE, and DELETE statements are single-table
operations. To generate INSERT statements that do use table aliases,
you must override prepareInsertExpressionWithRow: to
send a setUseAliases:YES
message
prior to invoking super
's version.
+ (BOOL)isColumnType:(id
<EOColumnTypes>)columnTypeA
equivalentToColumnType:(id <EOColumnTypes>)columnTypeB
options:(NSDictionary *)options
+ (NSString *)phraseCastingColumnNamed:(NSString
*)columnName
fromType:(id <EOColumnTypes>)type
toType:(id <EOColumnTypes>)castType
options:(NSDictionary *)options
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroup:(NSArray
*)entityGroup
EOSQLExpression's implementation creates a statement of the following form:
ALTER TABLE TABLE_NAME ADD PRIMARY KEY (PRIMARY_KEY_COLUMN_NAMES)
Where TABLE_NAME is the externalName for the first entity in entityGroup and PRIMARY_KEY_COLUMN_NAMES is a comma-separated list of the columnNames of the first entity's primaryKeyAttributes.
If the subclass's database server's primary key constraint semantics are different, the subclass should override this method.
+ (NSArray *)primaryKeyConstraintStatementsForEntityGroups:(NSArray
*)entityGroups
+ (NSArray *)primaryKeySupportStatementsForEntityGroup:(NSArray
*)entityGroup
create sequence SEQUENCE_NAME
Where SEQUENCE_NAME is the primaryKeyRootName: for the first entity in entityGroup concatenated with "_SEQ" (EMP_ID_SEQ, for example).
If a subclass uses a different primary key generation mechanism or if the subclass's database server's drop semantics are different, the subclass should override this method.
See Also: + dropPrimaryKeySupportStatementsForEntityGroup:, - primaryKeyForNewRowWithEntity: (EOAdaptorChannel)
+ (NSArray *)primaryKeySupportStatementsForEntityGroups:(NSArray
*)entityGroups
+ (NSArray *)schemaCreationScriptForEntities:(NSArray
*)entities
options:(NSDictionary *)options
+ (NSArray *)schemaCreationStatementsForEntities:(NSArray
*)entities
options:(NSDictionary *)options
EOSQLExpression's implementation uses the following methods:
to generate EOSQLExpressions for the support identified in options.
See Also: + schemaCreationScriptForEntities:options:
+ (EOSQLExpression *)selectStatementForAttributes:(NSArray
*)attributes
lock:(BOOL)flag
fetchSpecification:(EOFetchSpecification
*)fetchSpecification
entity:(EOEntity *)entity
NSInvalidArgumentException
if attributes
is nil or empty, fetchSpecification is nil,
or entity is nil.The expression
created with this method uses table aliases. To generate SELECT
statements that don't use them, you must override prepareSelectExpressionWithAttributes:lock:fetchSpecification: to send
a setUseAliases:NO
message
prior to invoking super
's
version.
+ (void)setUseBindVariables:(BOOL)flag
EOAdaptorUseBindVariables
is YES,
though, instances do use them. For more information on bind variables,
see the discussion in the class description.See Also: + useBindVariables
+ (void)setUseQuotedExternalNames:(BOOL)flag
EOAdaptorQuotesExternalNames
is YES,
though, instances do use quotes.See Also: + useQuotedExternalNames, - sqlStringForSchemaObjectName:, - externalNameQuoteCharacter
+ (NSString *)sqlPatternFromShellPattern:(NSString
*)pattern
EOQualifierOperatorLike
. EOSQLExpression's
implementation performs the following substitutionsCharacter in pattern | Substitution string |
* | % |
? | _ |
% | [%] (unless the percent character appears in square brackets) |
_ | [_] (unless the underscore character appears in square brackets) |
See Also: + sqlPatternFromShellPattern:withEscapeCharacter:
+ (NSString *)sqlPatternFromShellPattern:(NSString
*)pattern
withEscapeCharacter:(unichar)escapeCharacter
+ (NSArray *)statementsToConvertColumnNamed:(NSString
*)columnName
inTableNamed:(NSString *)tableName
fromType:(id <EOColumnTypes>)type
toType:(id <EOColumnTypes>)newType
options:(NSDictionary *)options
+ (NSArray *)statementsToCopyTableNamed:(NSString
*)tableName
intoTableForEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
The changes dictionary identifies the changes to make to the database schema; for more information, see "The Change Dictionary" . The options dictionary describes the aspects of the schema for which to create SQL statements; for more information, see "The Options Dictionary" .
+ (NSArray *)statementsToDeleteColumnNamed:(NSString
*)columnName
inTableNamed:(NSString *)tableName
options:(NSDictionary *)options
+ (NSArray *)statementsToDropForeignKeyConstraintsOnEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToDropPrimaryKeyConstraintsOnEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToDropPrimaryKeySupportForEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToImplementForeignKeyConstraintsOnEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToImplementPrimaryKeyConstraintsOnEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToImplementPrimaryKeySupportForEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToInsertColumnForAttribute:(EOAttribute
*)attribute
options:(NSDictionary *)options
+ (NSArray *)statementsToModifyColumnNamed:(NSString
*)columnName
inTableNamed:(NSString *)tableName
toNullRule:(BOOL)allowsNull
options:(NSDictionary *)options
+ (NSArray *)statementsToRenameColumnNamed:(NSString
*)columnName
inTableNamed:(NSString *)tableName
newName:(NSString *)newName
options:(NSDictionary *)options
+ (NSArray *)statementsToRenameTableNamed:(NSString
*)tableName
newName:(NSString *)newName
options:(NSDictionary *)options
+ (NSArray *)statementsToUpdateStoreForEntityGroup:(NSArray
*)entityGroup
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (NSArray *)statementsToUpdateObjectStoreForModel:(EOModel
*)model
withChangeDictionary:(NSDictionary
*)changes
options:(NSDictionary *)options
+ (BOOL)supportsDirectColumnCoercion
+ (BOOL)supportsDirectColumnDeletion
+ (BOOL)supportsDirectColumnInsertion
+ (BOOL)supportsDirectColumnNullRuleModification
+ (BOOL)supportsDirectColumnRenaming
+ (BOOL)supportsSchemaSynchronization
+ (EOSQLExpression *)updateStatementForRow:(NSDictionary
*)row
qualifier:(EOQualifier *)qualifier
entity:(EOEntity *)entity
Raises
an NSInvalidArgumentException
if row is nil
or
empty, qualifier is nil
,
or entity is nil
.
The
expression created with this method does not use table aliases because
Enterprise Objects Framework assumes that all INSERT, UPDATE, and
DELETE statements are single-table operations. As a result, all
keys in qualifier should be simple
key names; no key paths are allowed. To generate UPDATE statements
that do use table aliases, you must override prepareUpdateExpressionWithRow:qualifier: to
send a setUseAliases:YES
message
prior to invoking super
's
version.
See Also: - setUseAliases:
+ (BOOL)useBindVariables
See Also: + setUseBindVariables:
+ (BOOL)useQuotedExternalNames
See Also: + setUseQuotedExternalNames:, - sqlStringForSchemaObjectName:, - externalNameQuoteCharacter
- (void)addBindVariableDictionary:(NSMutableDictionary
*)binding
See Also: - bindVariableDictionaries
- (void)addCreateClauseForAttribute:(EOAttribute
*)attribute
EOSQLExpression's implementation creates clauses in the following form:
COLUMN_NAME COLUMN_TYPE ALLOWS_NULL_CLAUSE
Where
- (void)addInsertListAttribute:(EOAttribute
*)attribute
value:(NSString *)value
Invokes appendItem:toListString: to add an SQL string for attribute to the receiver's listString, and again to add a formatted SQL string for value to the receiver's valueList.
See Also: - sqlStringForAttribute:, - sqlStringForValue:attributeNamed:, + formatValue:forAttribute:
- (void)addJoinClauseWithLeftName:(NSString
*)leftName
rightName:(NSString *)rightName
joinSemantic:(EOJoinSemantic)semantic
See Also: - joinClauseString
- (void)addOrderByAttributeOrdering:(EOSortOrdering
*)sortOrdering
EOCompareCaseInsensitiveAscending
or EOCompareCaseInsensitiveAscending
,
the string generated has the format "upper(attribute) direction". Use
the method orderByString to
access the ORDER BY string. addOrderByAttributeOrdering: invokes appendItem:toListString: to add the
attribute-direction pair.See Also: - sqlStringForAttributeNamed:
- (void)addSelectListAttribute:(EOAttribute
*)attribute
See Also: - sqlStringForAttribute:, + formatSQLString:format:, - readFormat (EOAttribute)
- (void)addUpdateListAttribute:(EOAttribute
*)attribute
value:(NSString *)value
See Also: + formatSQLString:format:
- (NSMutableDictionary *)aliasesByRelationshipPath
See Also: - tableListWithRootEntity:
- (NSString *)allowsNullClauseForConstraint:(BOOL)flag
See Also: + addCreateClauseForAttribute:
- (void)appendItem:(NSString
*)itemString
toListString:(NSMutableString
*)listString
- (NSString *)assembleDeleteStatementWithQualifier:(EOQualifier
*)qualifier
tableList:(NSString *)tableList
whereClause:(NSString *)whereClause
DELETE FROM tableList SQL_WHERE whereClause
qualifier is the argument to prepareDeleteExpressionForQualifier: from which whereClause was derived. It is provided for subclasses that need to generate the WHERE clause in a particular way.
- (NSString *)assembleInsertStatementWithRow:(NSDictionary
*)row
tableList:(NSString *)tableList
columnList:(NSString *)columnList
valueList:(NSString *)valueList
INSERT INTO tableList (columnList) VALUES valueList
or, if columnList is nil:
INSERT INTO tableList VALUES valueList
row is the argument to prepareInsertExpressionWithRow: from which columnList and valueList were derived. It is provided for subclasses that need to generate the list of columns and values in a particular way.
- (NSString *)assembleJoinClauseWithLeftName:(NSString
*)leftName
rightName:(NSString *)rightName
joinSemantic:(EOJoinSemantic)semantic
leftName operator rightName
Where operator is "=" for an inner join, "*=" for a left-outer join, and "=*" for a right-outer join. Invoked from addJoinClauseWithLeftName:rightName:joinSemantic:.
- (NSString *)assembleSelectStatementWithAttributes:(NSArray
*)attributes
lock:(BOOL)lock
qualifier:(EOQualifier *)qualifier
fetchOrder:(NSArray *)fetchOrder
selectString:(NSString *)selectString
columnList:(NSString *)columnList
tableList:(NSString *)tableList
whereClause:(NSString *)whereClause
joinClause:(NSString *)joinClause
orderByClause:(NSString *)orderByClause
lockClause:(NSString *)lockClause
SELECT columnList FROM tableList lockClause WHERE whereClause AND joinClause ORDER BY orderByClause
If lockClause is nil, it is omitted from the statement. Similarly, if orderByClause is nil, the "ORDER BY orderByClause" is omitted. If either whereClause or joinClause is nil, the "AND" and nil-valued argument are omitted. If both are nil, the entire WHERE clause is omitted.
attributes, lock, qualifier, and fetchOrder are the arguments to prepareSelectExpressionWithAttributes:lock:fetchSpecification: from which the other assembleSelect... arguments were derived. They are provided for subclasses that need to generate the clauses of the SELECT statement in a particular way.
- (NSString *)assembleUpdateStatementWithRow:(NSDictionary
*)row
qualifier:(EOQualifier *)qualifier
tableList:(NSString *)tableList
updateList:(NSString *)updateList
whereClause:(NSString *)whereClause
UPDATE tableList SET updateList WHERE whereClause
row and qualifier are the arguments to prepareUpdateExpressionWithRow:qualifier: from which updateList and whereClause were derived. They are provided for subclasses that need to generate the clauses of the UPDATE statement in a particular way.
- (NSArray *)bindVariableDictionaries
See Also: - addBindVariableDictionary:
- (NSMutableDictionary *)bindVariableDictionaryForAttribute:(EOAttribute
*)attribute value:(id)value
Key | Corresponding Value |
EOBindVariableNameKey |
Name of the bind variable for attribute |
EOBindVariablePlaceHolderKey |
Placeholder string used in the SQL statement |
EOBindVariableAttributeKey |
attribute |
EOBindVariableValueKey |
value |
An adaptor subclass may define additional entries as required by its RDBMS.
Invoked from sqlStringForValue:attributeNamed: when the message mustUseBindVariableForAttribute:attribute returns YES or when the receiver's class uses bind variables and the message shouldUseBindVariableForAttribute:attribute returns YES. For more information on bind variables, see the discussion in the class description.
A subclass that uses bind variables should implement this method without invoking EOSQLExpression's implementation. The subclass implementation must return a dictionary with entries for the keys listed above and may add additional keys.
See Also: - bindVariableDictionaryForAttribute:value:, + useBindVariables
- (NSString *)columnTypeStringForAttribute:(EOAttribute
*)anAttribute
If Condition | Generated String |
precision is non-zero | externalType(precision, scale) |
precision is zero and width is non-zero | externalType(scale) |
precision and width are zero | externalType |
A subclass should override the default implementation if its database server requires column types in a different format.
See Also: - addCreateClauseForAttribute:
- (EOEntity *)entity
See Also: - initWithEntity:
- (NSString *)externalNameQuoteCharacter
See Also: + useQuotedExternalNames, - sqlStringForSchemaObjectName:
- initWithEntity:(EOEntity
*)entity
See Also: - entity
- (NSMutableString *)joinClauseString
An EOSQLExpression's joinClauseString is generally set by invoking joinExpression.
See Also: - addJoinClauseWithLeftName:rightName:joinSemantic:
- (void)joinExpression
If the aliasesByRelationshipPath dictionary only has one entry (the entry for the EOSQLExpression's entity), the joinClauseString is empty.
You
must invoke this method after invoking addSelectListAttribute: for each
attribute to be selected and after sending sqlStringForSQLExpression:self to
the qualifier for the SELECT statement. (These methods build up
the aliasesByRelationshipPath dictionary
by invoking sqlStringForAttributePath:.)
See Also: - whereClauseString, - sqlStringForSQLExpression: (EOQualifierSQLGeneration protocol)
- (NSMutableString *)listString
Type of Statement | Sample listString Contents |
INSERT | FIRST_NAME, LAST_NAME, EMPLOYEE_ID |
UPDATE | FIRST_NAME = "Timothy", LAST_NAME = "Richardson" |
SELECT | t0.FIRST_NAME, t0.LAST_NAME, t1.DEPARTMENT_NAME |
- (NSString *)lockClause
- (BOOL)mustUseBindVariableForAttribute:(EOAttribute
*)attribute
See Also: - shouldUseBindVariableForAttribute:, - bindVariableDictionaryForAttribute:value:
- (NSMutableString *)orderByString
See Also: - addOrderByAttributeOrdering:
- (void)prepareConstraintStatementForRelationship:(EORelationship
*)relationship
sourceColumns:(NSArray *)sourceColumns
destinationColumns:(NSArray *)destinationColumns
ALTER TABLE TABLE_NAME ADD CONSTRAINT CONSTRAINT_NAME FOREIGN KEY (SOURCE_KEY_LIST) REFERENCES DESTINATION_TABLE_NAME (DESTINATION_KEY_LIST)
Where
See Also: + foreignKeyConstraintStatementsForRelationship:
- (void)prepareDeleteExpressionForQualifier:(EOQualifier
*)qualifier
:self
message
to qualifier to generate the receiver's whereClauseString.See Also: + deleteStatementWithQualifier:entity:
- (void)prepareInsertExpressionWithRow:(NSDictionary
*)row
See Also: + insertStatementForRow:entity:
- (void)prepareSelectExpressionWithAttributes:(NSArray
*)attributes
lock:(BOOL)flag
fetchSpecification:(EOFetchSpecification
*)fetchSpecification
:self message
to fetchSpecification's qualifier
to generate the receiver's whereClauseString. See Also: + selectStatementForAttributes:lock:fetchSpecification:entity:
- (void)prepareUpdateExpressionWithRow:(NSDictionary
*)row
qualifier:(EOQualifier *)qualifier
:self message
to qualifier to generate the receiver's whereClauseString.See Also: + updateStatementForRow:qualifier:entity:
- (void)setStatement:(NSString
*)string
See Also: + expressionForString:, - statement
- (void)setUseAliases:(BOOL)flag
See Also: - useAliases
- (BOOL)shouldUseBindVariableForAttribute:(EOAttribute
*)attribute
See Also: - mustUseBindVariableForAttribute:
- (NSString *)sqlStringForAttribute:(EOAttribute
*)attribute
See Also: - sqlStringForAttributePath:
- (NSString *)sqlStringForAttributeNamed:(NSString
*)name
- (NSString *)sqlStringForAttributePath:(NSArray
*)path
Assuming that the receiver uses aliases and the alias for the Location table is t2, the SQL string for this sample attribute path is "t2.officeNumber".
If the receiver uses table aliases, this method has the side effect of adding a "relationship path"-"alias name" entry to the aliasesByRelationshipPath dictionary.
See Also: - sqlStringForAttribute:, - aliasesByRelationshipPath
- (NSString *)sqlStringForValue:(NSString
*)valueString
caseInsensitiveLikeKey:(NSString
*)keyString
- (NSString *)sqlStringForConjoinedQualifiers:(NSArray
*)qualifiers
self
as
the argument. If the SQL string for a qualifier contains only white
space, it isn't included in the return value. The return value
is enclosed in parentheses if the SQL strings for two or more qualifiers
were ANDed together.- (NSString *)sqlStringForDisjoinedQualifiers:(NSArray
*)qualifiers
- (NSString *)sqlStringForKeyComparisonQualifier:(EOKeyComparisonQualifier
*)qualifier
- (NSString *)sqlStringForKeyValueQualifier:(EOKeyValueQualifier
*)qualifier
EOQualifierOperatorLike
.)- (NSString *)sqlStringForNegatedQualifier:(EOQualifier
*)qualifier
Generates an SQL string for qualifier by sending an sqlStringForSQLExpression: message to qualifier with self as the argument. If the SQL string for qualifier contains only white space, this method returns nil.
- (NSString *)sqlStringForSchemaObjectName:(NSString
*)name
See Also: + useQuotedExternalNames, - externalNameQuoteCharacter
- (NSString *)sqlStringForSelector:(SEL)selector
value:(id)value
Selector (Constant) | SQL Operator |
EOQualifierOperatorIsEqual |
"is" if value is an EONull, "=" otherwise |
EOQualifierOperatorNotEqual |
"is not" if value is an EONull, "<>" otherwise |
EOQualifierOperatorLessThan |
"<" |
EOQualifierOperatorGreaterThan |
">" |
EOQualifierOperatorLessThanOrEqualTo |
"<=" |
EOQualifierOperatorGreaterThanOrEqualTo |
">=" |
EOQualifierOperatorLike |
"like" |
Raises an NSInternalInconsistencyException
if selector is
an unknown operator.
See Also: - sqlStringForKeyComparisonQualifier:, - sqlStringForKeyValueQualifier:
- (NSString *)sqlStringForValue:(id)value
attributeNamed:(NSString *)name
See Also: - mustUseBindVariableForAttribute:, - shouldUseBindVariableForAttribute:, + useBindVariables, - bindVariableDictionaries, - addBindVariableDictionary:
- (NSString *)statement
- (NSString *)tableListWithRootEntity:(EOEntity
*)entity
EMPLOYEE t0, DEPARTMENT t1
tableListWithRootEntity: creates a string containing the table name for entity and a corresponding table alias ("EMPLOYEE t0", for example). For each entry in aliasesByRelationshipPath, this method appends a new table name and table alias.
See Also: - useAliases, - aliasesByRelationshipPath
- (BOOL)useAliases
SELECT t0.FIRST_NAME, t0.LAST_NAME, t1.NAME FROM EMPLOYEE t0, DEPARTMENT t1 WHERE t0.DEPARTMENT_ID = t1.DEPARTMENT_ID
The EMPLOYEE table has the alias t0, and the DEPARTMENT table has the alias t1.
By default, EOSQLExpression uses table aliases only in SELECT statements. Enterprise Objects Framework assumes that INSERT, UPDATE, and DELETE statements are single-table operations. For more information, see the discussion in the class description.
See Also: - setUseAliases:, - aliasesByRelationshipPath
- (NSMutableString *)valueList
INSERT EMPLOYEE (FIRST_NAME, LAST_NAME, EMPLOYEE_ID, DEPARTMENT_ID, SALARY) VALUES ('Shaun', 'Hayes', 1319, 23, 4600)
is
"‘Shaun', ‘Hayes', 1319, 23, 4600". An EOSQLExpression's valueList
is
generated a value at a time with addInsertListAttribute:value: messages.
- (NSString *)whereClauseString
WHERE EMPLOYEE.SALARY > 4500 AND DEPARTMENT.NAME = ‘Finance' AND EMPLOYEE.DEPARTMENT_ID = DEPARTMENT.DEPARTMENT_ID
EOSQLExpression generates both a whereClauseString and a joinClauseString for this qualifier. The whereClauseString qualifies the rows and looks like this:
EMPLOYEE.SALARY > 4500 AND DEPARTMENT.NAME = ‘Finance'
The joinClauseString specifies the join conditions between the EMPLOYEE table and the DEPARTMENT table and looks like this:
EMPLOYEE.DEPARTMENT_ID = DEPARTMENT.DEPARTMENT_ID
An EOSQLExpression's whereClauseString is generally set by sending a sqlStringForSQLExpression: message to an EOQualifier object.
See Also: - sqlStringForSQLExpression: (EOQualifierSQLGeneration protocol)