lucee.Componentcborm.sql.SQLHelper
Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp www.ortussolutions.com --- Simple utility for extracting SQL from native Criteria Query objects
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
boolean
|
formatSql
Format the SQL or not.
|
false
|
true
|
false
|
array
|
log
The log array.
|
true
|
false
|
|
boolean
|
returnExecutableSql
Bit to return the executable SQL or not.
|
false
|
true
|
false
|
Constructor Summary | |
---|---|
init(any criteriaBuilder, [boolean returnExecutableSql='false'], [boolean formatSql='false'])
Constructor. |
Method Summary | |
---|---|
string
|
applyFormatting(string sql)
Applies pretty formatting to a sql string. |
private array
|
bindLimitParameters(array positionalValues, boolean append, any selection)
Inserts parameter values into the running list based on the dialect of the database engine. |
boolean
|
canLogLimitOffset()
Is there a limit in the logging offset. |
private array
|
convertToCFArray(any array)
Small utility method to convert weird arrays from Java methods into something CF understands. |
string
|
generateSQLAlias()
Generates a unique SQL Alias within the criteria query. |
private any
|
getCriteriaJoinWalker()
gets an instance of CriteriaJoinWalker, which can allow for translating criteria query into a sql string. |
private any
|
getCriteriaQueryTranslator()
gets an instance of CriteriaQueryTranslator, which can prepares criteria query for conversion to SQL. |
any
|
getDialect()
Retrieves the correct dialect of the database engine. |
private numeric
|
getFirstRow(any selection)
Gets the first row (or 0) for the current row selection. |
string
|
getFormatSql()
|
string
|
getLog()
|
private numeric
|
getMaxOrLimit(any selection)
Gets correct "limit" value for the current row selection. |
array
|
getPositionalSQLParameters()
Returns a formatted array of parameter value and types. |
any
|
getPositionalSQLParameterTypes(boolean simple='true')
Gets positional SQL parameter types from the criteria query. |
array
|
getPositionalSQLParameterValues()
Gets the positional SQL parameter values from the criteria query. |
any
|
getProjectedTypes()
Retrieves the projected types of the criteria query. |
string
|
getProjectionAlias()
Get the alias of the current projection. |
private any
|
getQueryParameters()
Gets currently applied query parameters for the query object. |
string
|
getReturnExecutableSql()
|
string
|
getRootSQLAlias()
Retrieves the "rooted" SQL alias for the criteria query. |
string
|
getSQL(boolean returnExecutableSql='[runtime expression]', boolean formatSql='[runtime expression]')
Returns the SQL string that will be prepared for the criteria object at the time of request. |
private boolean
|
hasMaxRows(any selection)
Determines whether the current row selection has a limit already applied. |
SQLHelper
|
log(string label='Criteria')
Logs current state of criteria to internal tracking log. |
private string
|
replaceQueryParameters(string sql)
replace query parameter placeholders with their actual values (for detachedSQLProjection). |
any
|
setFormatSql(boolean formatSql)
|
any
|
setLog(array log)
|
any
|
setReturnExecutableSql(boolean returnExecutableSql)
|
private boolean
|
useLimit(any selection)
Determines whether the database engine allows for the use of "limit/offset" syntax. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Constructor
criteriaBuilder
- The builder this helper is linked toreturnExecutableSql
- To return the executable SQL or notformatSql
- Pretty format the SQL or notProperty Detail |
---|
Format the SQL or not.
access
- publicrequired
- falsereturntype
- anyserializable
- trueThe log array
access
- publicrequired
- falsereturntype
- anyserializable
- trueBit to return the executable SQL or not
access
- publicrequired
- falsereturntype
- anyserializable
- trueMethod Detail |
---|
Applies pretty formatting to a sql string
sql
- The SQL string to formatInserts parameter values into the running list based on the dialect of the database engine
positionalValues
- The positional values for this queryappend
- Whether values are appended or prepended to the arrayselection
- The current row selectionIs there a limit in the logging offset
Small utility method to convert weird arrays from Java methods into something CF understands return Array
array
- {Array} The array to convertGenerates a unique SQL Alias within the criteria query
gets an instance of CriteriaJoinWalker, which can allow for translating criteria query into a sql string
gets an instance of CriteriaQueryTranslator, which can prepares criteria query for conversion to SQL
Retrieves the correct dialect of the database engine
Gets the first row (or 0) for the current row selection
selection
- The current row selectionGets correct "limit" value for the current row selection
selection
- The current row selectionReturns a formatted array of parameter value and types
Gets positional SQL parameter types from the criteria query
simple
- Whether to return a simply array or full objectsGets the positional SQL parameter values from the criteria query return array
Retrieves the projected types of the criteria query
Get the alias of the current projection
Gets currently applied query parameters for the query object return org.hibernate.engine.QueryParameters
Retrieves the "rooted" SQL alias for the criteria query
Returns the SQL string that will be prepared for the criteria object at the time of request
returnExecutableSql
- Whether or not to do query param replacements on returned SQL stringformatSql
- Whether to format the sqlDetermines whether the current row selection has a limit already applied
selection
- The current row selectionLogs current state of criteria to internal tracking log
label
- The label for the log recordreplace query parameter placeholders with their actual values (for detachedSQLProjection)
sql
- The sql string to massageformatSql
log
returnExecutableSql
Determines whether the database engine allows for the use of "limit/offset" syntax
selection
- The current row selection