Skip to content

Switch default naming strategy to camelCase and add support for nulls treatment in order by clause

Compare
Choose a tag to compare
@thetutlage thetutlage released this 25 Jan 04:39
· 41 commits to develop since this release

Breaking change

  • In this release we switch the naming strategy of the ORM and the Paginator to return camelCase output for the serialized object keys. This should have made its way in the last release, but somehow missed it. You can switch back to SnakeCase strategy by explicitly assigning it to the BaseModel. https://lucid.adonisjs.com/docs/model-naming-strategy

Switching back to snake_case naming strategy

If you like to keep using the old snake case naming strategy, then you can copy-paste the following code inside a service provider of your application.

import { SnakeCaseNamingStrategy } from '@adonisjs/lucid/orm'
import { BaseModel } from '@adonisjs/lucid/orm'

export default class AppProvider {
  async boot() {
     BaseModel.namingStrategy = new SnakeCaseNamingStrategy()
  }
}

New features

Add support for defining treatment of null values in orderBy method. For example:

orderBy([
  { column: 'expires_at', order: 'desc', nulls: 'last' },
  { column: 'last_used_at', order: 'desc', nulls: 'first' }
])

The above method calls will add compile to ORDER BY expires_at desc NULLS LAST and ORDER BY last_used_at desc NULLS FIRST sql statements

Commits

  • feat: add support for nulls property for orderby method signature b4af593
  • chore(package): update dependencies 4777edc
  • chore: remove @types/pluralize from dependencies cee062c
  • Merge pull request #986 from adonisjs/feat/serialize_to_camelcase d33b9b1
  • refactor: use camelCase naming strategy with paginator also 7e35cc2
  • fix: remove unused imports d327871
  • feat: change naming strategy to output camelCase key names in serialized output c835376
  • chore: update dependencies 718c68f
  • fix(seeds): correct log for ignored seed 71708b8

What's Changed

  • Breaking change - Switch ORM naming strategy to CamelCase by @thetutlage in #986
  • chore: remove @types/pluralize from dependencies by @targos in #987

Full Changelog: v19.0.0...v20.0.0