public class MySQLExpression extends _MySQLPlugIn.MySQLExpression
Overrides the default EOF MySQLExpression to adjust the sql generation of string comparisons.
MySQL's default behaviour, as per usual, is to ignore the standards. Thus an
sql like
performs a case insensitive comparison rather than case
sensitive which is vexing.
To enforce standard behaviour you can tell mysql by using
like binary
for a case sensitive comparison. Thus a case
insensitive comparison simply requires using a like
in order to
obtain the results desired.
Note: This assumes that you're not using binary columns.
The alternative is to define all of your columns as binary columns and specifically specify the collation to use for case insensitive comparisons. But that's a more complex approach in the author's view.
Another approach is to only ever use qualifiers and sort orderings that are case sensitive (semantically) and choose in your model what external type to map to in order to control the behaviour. In my view this is bad practice because you're separating the logic of queries and returning results that are not intended according to the code.
To summarise, if this class is enabled:
Name | Description |
---|---|
com.webobjects.jdbcadaptor.MySQLExpression.enable | set to true to enable this class and change the behavior of the
like operator to be case-insensitive. |
_MySQLPlugIn.MySQLExpression.JoinClauseDefinition
EOSQLExpression.SQLValue
_externalQuoteChar, _inSelect, _jdbcInfo, _rtrimFunctionName
_aliasesByRelationshipPath, _bindings, _contextStack, _defaultDateFormatter, _entity, _joinClauseString, _listString, _NibbleToHex, _orderByString, _statement, _upperFunctionName, _useAliases, _valueListString, _whereClauseString, BindVariableAttributeKey, BindVariableColumnKey, BindVariableNameKey, BindVariablePlaceHolderKey, BindVariableValueKey
Constructor and Description |
---|
MySQLExpression(EOEntity entity) |
Modifier and Type | Method and Description |
---|---|
void |
addOrderByAttributeOrdering(EOSortOrdering sortOrdering) |
protected void |
appendItemToOrderByString(String sqlString) |
protected Pattern |
likeOperatorRegex() |
protected String |
replaceStringForCaseInsensitiveLike(String string) |
protected String |
replaceStringForCaseSensitiveLike(String string) |
String |
sqlStringForCaseInsensitiveLike(String valueString,
String keyString) |
String |
sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier) |
String |
sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier) |
protected Pattern |
upperFunctionNameRegex() |
addJoinClause, assembleJoinClause, assembleSelectStatementWithAttributes, externalNameQuoteCharacter, joinClauseString, joinExpression, prepareSelectExpressionWithAttributes, sqlEscapeChar
addSelectListAttribute, allowsNullClauseForConstraint, appendItemToListString, appendItemToValueListString, bindVariableDictionaryForAttribute, columnTypeStringForAttribute, formatValueForAttribute, jdbcInfo, lockClause, mustUseBindVariableForAttribute, setJDBCInfo, shouldUseBindVariableForAttribute, useBindVariables
_aliasForRelatedAttributeRelationshipPath, _aliasForRelationshipPath, _defaultDateFormatter, _entityForRelationshipPathOrigin, _flattenRelPathEntity, _listString, _orderByString, _rootEntityForExpression, _setEntity, _sqlStringForJoinSemanticMatchSemantic, _stringForDate, _truncatedString, _truncatedStringForData, _valueList, addBindVariableDictionary, addCreateClauseForAttribute, addInsertListAttribute, addUpdateListAttribute, aliasesByRelationshipPath, appendItemToListString, assembleDeleteStatementWithQualifier, assembleInsertStatementWithRow, assembleUpdateStatementWithRow, bindVariableDictionaries, entity, formatSQLString, formatStringValue, listString, orderByString, prepareConstraintStatementForRelationship, prepareDeleteExpressionForQualifier, prepareInsertExpressionWithRow, prepareUpdateExpressionWithRow, setStatement, setUseAliases, setUseBindVariables, setUseQuotedExternalNames, sqlPatternFromShellPattern, sqlPatternFromShellPatternWithEscapeCharacter, sqlStringForAttribute, sqlStringForAttributeNamed, sqlStringForAttributePath, sqlStringForConjoinedQualifiers, sqlStringForData, sqlStringForDisjoinedQualifiers, sqlStringForNegatedQualifier, sqlStringForNumber, sqlStringForQualifier, sqlStringForSchemaObjectName, sqlStringForSelector, sqlStringForString, sqlStringForValue, statement, tableListWithRootEntity, toString, useAliases, useQuotedExternalNames, valueList, whereClauseString
public MySQLExpression(EOEntity entity)
entity
- public void addOrderByAttributeOrdering(EOSortOrdering sortOrdering)
addOrderByAttributeOrdering
in class EOSQLExpression
EOSQLExpression.addOrderByAttributeOrdering(com.webobjects.eocontrol.EOSortOrdering)
protected void appendItemToOrderByString(String sqlString)
appendItemToOrderByString
in class JDBCExpression
JDBCExpression.appendItemToOrderByString(java.lang.String)
protected Pattern likeOperatorRegex()
protected String replaceStringForCaseInsensitiveLike(String string)
public String sqlStringForCaseInsensitiveLike(String valueString, String keyString)
public String sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier)
public String sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier)
protected Pattern upperFunctionNameRegex()
Copyright © 2002 – 2024 Project Wonder.