Better Support for OracleGrammar in SchemaBuilder
Fix trigger creation by escaping colons (:
).
Try to drop associated sequences and triggers when dropping a table.
Allow for setting a defaultSchema
property on a SchemaBuilder
instance.
The defaultSchema
will be used for methods like hasTable
and hasColumn
. A passed in schema
will still take precedence.
Use CHAR
for GUID
and UUID
types in MySQL.
Don't call getUtils
from inside QueryUtils
.
Make replaceBindings
publicly available in QueryUtils
.
This is used by qb to inline query bindings in toSQL
or dump
calls and can be used to inline the bindings in other tools like CommandBox Migrations.
Use named parameters when passing to BaseGrammar
. This avoids problems where custom Grammars have extra arguments and we add arguments to the official grammar.
We apologize for the new features in a patch release.
Add the ability to pretend to run queries, both in QueryBuilder and SchemaBuilder.
Add query logging to QueryBuilder and SchemaBuilder instances.
Use varchar for clob when converting to a CFML query. This is used when removing a column like in Oracle pagination.
Handle more numeric SQL types like AtomicInteger
and Long
.
Add millisecond accuracy to inline bindings.
Separate having
bindings from where
bindings.
We now support the returning
function inside update
and delete
statements for supported Grammars. Supported grammars are SQL Server, Postgres, and SQLite.
Fix raw table name parsing in update queries for SqlServerGrammar
.
Fix truncating text in nested wheres inside joins.
Fix out of order bindings in joinSub
Switch from table_catalog
to table_schema
when referencing schema for PostgresGrammar
.
CommandBox-friendly injections for SQL Commenter.
Add support for from
bindings, used especially in fromSub
queries.
This release reverts the use of native returntype
s. There are too many bugs between engine implementations to make it viable. No end-user changes should be visible.
Make withReturnFormat
a public method.
Add ability to inline bindings when calling toSQL
and dump
. These strings can be executed in a DBMS application.
Move coldbox
namespace injection to the function body so CommandBox doesn't blow up.
Correctly apply native returntypes after newQuery
and withReturnFormat
.
Fix losing defaultOptions
when calling newQuery
.
Shortcut for no return format using none
.
Allow for native struct returntypes. Requires a return format of none
.
Fix RouteInfoCommenter
file name.
Adobe has ended support for ACF 2016, and so must we.
CFML's uuid
does not match other languages; it's one character shorter. Because of this, the value from createUUID()
cannot be used in some database column types like SQL Server's uniqueidentifier
. This made for some confusion in SchemaBuilder since it wasn't clear if uuid
meant CFML's definition or the wider world's definition.
So, the types have been split, following Lucee's pattern, into uuid
(matching CFML's createUUID()
) and guid
(matching Java's UUID or createGUID()
on Lucee).
Popular grid frameworks like Quasar and Datatables use values of 0 or -1 to return all rows from a query. This is now supported in qb. Previously, it generated an invalid query (SELECT * FROM users LIMIT 0 OFFSET 0
).
This behavior can be customized by providing a callback to the shouldMaxRowsOverrideToAll
setting or init
argument. For instance, to revert to the previous behavior you would set the function as follows:
autoDeriveNumericType
is now the defaultIntroduced in 8.10.0, this feature uses separate SQL types for integers and decimals to increase performance in certain database grammars. This feature is now the default, but the previous behavior can be enabled by setting autoDeriveNumericType
to false
.
Note: the option to revert to the old behavior will be removed in the next major version.
strictDateDetection
is now the defaultIntroduced in 8.1.0, this feature only returns a SQL type of CF_SQL_TIMESTAMP
if the param is a date object, not just a string that looks like a date. This helps avoid situations where some strings were incorrectly interpreted as dates. For many, the migration path is straightforward — calls to now()
are already date objects as well as any function that operates on a date. If you need to parse a string as a date, the parseDateTime
built-in function can accomplish that.
Note: the option to revert to the old behavior may be removed in the next major version.
Thanks to Jason Steinhouer, qb now supports SQLite for both QueryBuilder
and SchemaBuilder
. You can use it in your apps by specifying SQLiteGrammar@qb
as the default grammar.
sqlCommenter is a specification by Google for adding contextual information as a comment at the end of a SQL statement. This can give insights into your application, especially when diagnosing slow queries. Examples of the information you can append to your queries are route
, handler
, action
, version
, and others, as well as the ability to add your own, such as loggedInUser
and more.
There's a new shortcut method to return qb.sum( qb.raw( expression ) )
. You're welcome. 😉
dropIndex
methodSome grammars, like SQL Server, do not treat simple indexes as constraints. For this reason, we've added a dropIndex
method alongside the existing dropConstraint
.
columnList
helper methodcolumnList
will return either an array of column names for the configured table or the query that is generated by cfdbinfo
for the configured table. Especially useful when working with dynamically generated grids.
Correctly compile insertUsing
statements that use Common Table Expressions (CTEs).
Update announceInterception
calls for ColdBox 7. (Thank you, Michael Born.)
Fixed insertUsing
not placing Common Table Expressions (CTEs) in the correct order.
Added the missing keyword in the Postgres upsert
syntax.
Don't add DISTINCT
when doing a COUNT(*)
.
Support aggregates for unioned queries.
Add a firstOrFail
fetch method inspired by Quick.
There are now specific numeric SQL types for integers and decimals used during the inferSQLType
check in QueryUtils
. This is an opt-in feature, enabled by setting the autoDeriveNumericType
setting. The previous approach was to use CF_SQL_NUMERIC
for all numeric types which could cause performance issues in some grammars as they interpreted all CF_SQL_NUMERIC
as floating point numbers.
HOLDLOCK
and READPAST
are mutually exclusive table locks in SQL Server but were mistakenly being applied together.
Specify defaultOptions
inside of your ColdBox config.
Better parsing of raw
statements when deriving insertUsing
columns.
Insert data based off of a callback or builder using insertUsing
.
Insert data ignoring duplicate key errors using insertIgnore
.
Use a callback or builder as the source for an upsert
statement.
Allow for deleting unmatched source records in upserts (SQL Server only).
Add a new skipLocked
flag to lockForUpdate
.
Don't uppercase quoted aliases in Oracle.
Fix for aliases in update statements.
Don't sort columns for insertUsing
.
Add subquery bindings in insert and upsert statements.
Maintain column order when using source in upsert.
Fix for Oracle returning custom column types when renaming a column.
Explicit arguments scoping.
arrayEach
is slow compared to merging arrays.
Fix wheres with joins in update statements.
Add better null handling to inferSqlType
.
Correctly format columns being updated.
Add an upsert method. upsert
can update or insert multiple records at once depending on if a column is matched.
Allow JOIN
statements in UPDATE
statements. (This is not supported on Oracle.)
Allow updates with subselects using closures or builder instances.
Better handling of group by
and having
clauses in pagination queries.
Allow any value to be returned from aggregates including strings, numbers, and dates.
Correctly wrap CTE expressions with parenthesis when required in certain grammars.
SchemaBuilder
can now be configured with default query options. (Default options will still be overridden by options passed to each SchemaBuilder
method.)
Add a reset
method to QueryBuilder.
Add locking helpers such as lock
, noLock
, lockForUpdate
, and sharedLock
.
Correct return aggregate values for date values from max
and min
executors.
Automatically add a scale
to an incoming query param when needed.
Add a whereNotLike
shortcut method.
Correctly format a COUNT(DISTINCT column)
query.
Only use bulk insert syntax when needed in OracleGrammar due to interactions between the result
parameter to cfquery
, Lucee, and the Oracle JDBC driver.
Add support for stored computed columns and virtual computed columns.
Swap master
branch to main
branch.
Remove unnecessary injection for QueryUtils.
Account for raw expressions when generating mementos for comparison
Add support for mediumtext & longtext types for MySQLGrammar.
Fix limit on simplePaginate.
Migrate release process to GitHub Actions.
Add a simplePaginate
pagination method for quicker performance when total records or total pages are not needed or too slow.
Introduce a numericSQLType
setting to specify the default numeric SQL type.
Default to html
for the dump
format argument to writeDump
.
Correctly use the passed in strictDateDetection
to the QueryUtils.cfc
.
Added a dump
command to aid in debugging a query while chaining.
orderByRaw
now can accept bindings.
A new, optional strictDateDetection
setting is available to check the underlying Java class of a date object instead of using isDate
.
Ignore select bindings for aggregate queries.
Allow spaces in table aliases.
Split FLOAT and DECIMAL column types in SQL Server.
Clear orderBy bindings when calling clearOrders
.
Trim table definitions before searching for aliases. Makes qb more lenient with extra whitespace.
``when
callbacks now automatically scope and group where clauses when an OR
combinator is used.
Combine clearOrders
and orderBy
with a new reorder
method.
Clear current selected columns with clearSelect
.
Combine clearSelect
and either select
or selectRaw
with reselect
and reselectRaw
respectively.
Expose nested where functions to enable advanced query manipulation in downstream libraries like Quick.
Fixes for OracleGrammar including table aliases and wrapped subqueries.
Allow nullable timestamps in MySQL.
Return 0 on null aggregates.
Match type hints to documentation for join functions
Handle enhanced numeric checks with Secure Profile enabled.
Allow raw statements in basic where clauses.
Allow for space-delimited sort directions like column DESC
.
``value
and values
now work with column formatters.
Correctly format RETURNING clauses with column formatters and ignoring table qualifiers.
Handle multi-word columns in queryRemoveColumns
.
Remove elvis operator due to ACF compatibility issues
Add support for MONEY and SMALLMONEY data types to SchemaBuilder.
Fix wrapping of enum types for Postgres.
Compatibility fix for ACF 2018 and listLast
parsing.
Include current_timestamp default for timestamp
columns in SchemaBuilder.
Ignore table qualifiers for insert and update.
Fix a bug with preventDuplicateJoins when using the closure syntax with a join.
Add executionTime to the data output from BaseGrammar, including being available in interceptors.
Fix a case where a column was not wrapped correctly when a where
used a subquery for the value.
Avoid duplicate
function due to cbORM / Hibernate bugs when used in the same application.
Split off a private whereBasic
method. This is used in Quick to provide extra sql type features.
Add a clearOrders
method. Any already configured orders are cleared. Any orders added after this call will be added as normal.
selectRaw
now can take an array of expressions.
Fixed an issue using column formatters with update
and insert
.
Using a new preventDuplicateJoins
setting in the module settings, qb can detect duplicate joins and ignore them. This is especially useful in a heavily filtered and dynamic query where you may or may not need the join at all or more than one column may need the same join. preventDuplicateJoins
defaults to false
, so it is opt-in. It may be turned on by default in a future breaking release of qb.
Enhance order by's with more direction options (c767ac8)
You can now use two shortcut methods: orderByAsc
and orderByDesc
. Additionally, orderBySub
or using orderBy
with a closure or builder instance will respect the direction argument.
Fix using whereBetween
with query param structs (07c9b72)
Ignore orders in aggregate queries (39e1338)
Format with cfformat (dc2a9b6)
Improve column wrapping with trimming (d98a5cb)
Prefer the parent query over magic methods when the parent query has the exact method. (f9fd8d1)
Switch to using ForgeBox Storage.
Allow passing query options in to paginate (cdecfb3)
Fix for inserting null values directly (1de27a6)
Use cfformat for automatic formatting (119e434)
Add a type to the onMissingMethod exception (90d1093)
Correctly wrap comments in MySQLGrammar
.
Publish qb apidocs to Ortus API Docs.
Fix for null values breaking the new checkIsActuallyNumeric
method in QueryUtils
.
Add a parameterLimit
public property to SqlServerGrammar
. This property is used in Quick to split up eager loading to work around the 2100 param limit of SQL Server.
Allow a parent query to be set. A parent query will receive any method calls that are not found on the Query Builder instance. This is especially useful for instances like Quick to allow Quick features like scopes to be available inside any closures.
Lambdas (arrow functions) are now allowed wherever closures are allowed.
Add an orderByRaw
method.
Please see the Migration Guide for more information on these changes.
Drop support for Lucee 4.5 and Adobe ColdFusion 11.
MSSQLGrammar
renamed to SqlServerGrammar
Remove variadic parameters support in builder functions like select
.
The defaultGrammar
mapping needs to be the full WireBox mapping, including the @qb
, if needed.
For instance, MSSQLGrammar
would become MSSQLGrammar@qb
.
This will allow for other grammars to be more easily contributed via third party modules.
The argument names of forPage
changed to match the new paginate
method.
Add defaultValue
and optional exception throwing to value
. (This changed the argument order.)
All methods that could conceivably take a subquery as well as a value now accept a closure or another builder instance to use as a subquery. (This changed the argument names in some instances.)
Completely revamped documentation! (You're looking at it right now.)
Add new flag to toSQL( showBindings = true )
to replace question marks (?
) with cfqueryparam
-compatible structs for debugging.
Preserve column case and order when converting a query to an array using the default "array"
return format.
Add a new paginate method to generate a pagination struct alongside the results. This can be customized using a custom PaginationCollector.
Allow raw values in insert
calls.
Allow default queryExecute
options
to be configure at a Query Builder level. This also enables custom QueryBuilders
a la Hyper.
Add a whereLike
method.
Allow closures to be used in left and right joins.
Provide an addUpdate
method to programmatically build the SET
clause of an update query.
Add a new chunk
method to grab records from the database in small sets.
Add raw
in alterTable
segments.
Add dropAllObjects
support for SqlServerGrammar
and OracleGrammar
to support migrate fresh
from cfmigrations.
Add a renameTable
alias for rename
.
Remove default constraints when dropping columns with a default on SqlServerGrammar
.
Add more column types and column helpers to SchemaBuilder
, including:
datetimeTz
lineString
nullableTimestamps
point
polygon
softDeletes
softDeletesTz
timeTz
timestamps
timestampTz
timestampsTz
withCurrent
****