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:
| Properties | |
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.JoinClauseDefinitionEOSQLExpression.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(java.lang.String sqlString) |
protected java.util.regex.Pattern |
likeOperatorRegex() |
protected java.lang.String |
replaceStringForCaseInsensitiveLike(java.lang.String string) |
protected java.lang.String |
replaceStringForCaseSensitiveLike(java.lang.String string) |
java.lang.String |
sqlStringForCaseInsensitiveLike(java.lang.String valueString,
java.lang.String keyString) |
java.lang.String |
sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier) |
java.lang.String |
sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier) |
protected java.util.regex.Pattern |
upperFunctionNameRegex() |
addJoinClause, assembleJoinClause, assembleSelectStatementWithAttributes, externalNameQuoteCharacter, joinClauseString, joinExpression, prepareSelectExpressionWithAttributes, sqlEscapeCharaddSelectListAttribute, 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, whereClauseStringpublic MySQLExpression(EOEntity entity)
entity - public void addOrderByAttributeOrdering(EOSortOrdering sortOrdering)
addOrderByAttributeOrdering in class EOSQLExpressionEOSQLExpression.addOrderByAttributeOrdering(com.webobjects.eocontrol.EOSortOrdering)protected void appendItemToOrderByString(java.lang.String sqlString)
appendItemToOrderByString in class JDBCExpressionJDBCExpression.appendItemToOrderByString(java.lang.String)protected java.util.regex.Pattern likeOperatorRegex()
protected java.lang.String replaceStringForCaseInsensitiveLike(java.lang.String string)
protected java.lang.String replaceStringForCaseSensitiveLike(java.lang.String string)
public java.lang.String sqlStringForCaseInsensitiveLike(java.lang.String valueString,
java.lang.String keyString)
public java.lang.String sqlStringForKeyComparisonQualifier(EOKeyComparisonQualifier qualifier)
public java.lang.String sqlStringForKeyValueQualifier(EOKeyValueQualifier qualifier)
protected java.util.regex.Pattern upperFunctionNameRegex()
Copyright © 2002 – 2022 Project Wonder.