• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gajus / slonik / 562 / 2
89%
master: 89%

Build:
DEFAULT BRANCH: master
Ran 19 Sep 2019 06:56PM UTC
Files 66
Run time 10s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

19 Sep 2019 06:50PM UTC coverage: 68.828% (-8.6%) from 77.461%
562.2

push

travis-ci

gajus
feat: remove multiple methods in favor of sql.join
BREAKING CHANGE:

The latest changes remove a large number of helper methods for building queries:

* `assignmentList`
* `booleanExpression`
* `comparisonPredicate`
* `identifierList`
* `rawList`
* `tuple`
* `tupleList`
* `valueList`

The original motivation for having these methods was to provide static types that are specific to different contexts of the query (e.g. identifier list containing only of identifier tokens). However, as programs using Slonik grew in complexity, so did the requirements for having more complex expressions: a requirement to support any SQL expressions in all of the contexts became evident. This made strict types less useful.

Meanwhile, the API has proliferated with a long list of methods that carry semantic significance but do not significantly differ in their functionality. This created an unnecessary steep learning curve for new adopters and confusing code when any of those methods is misused (e.g. describing value list using tuple list would create confusion about the intent of the code).

All of the removed methods shared a common requirement: to create an expression consisting of a dynamic number of members. This requirement was implemented using a new method `sql.join`. `sql.join` works similar to `Array.join` and it can be used to express any of the above methods, e.g.

```js
sql.tuple(['foo', 'bar'])

```

can be writen as:

```js
sql`
  (${sql.list([
    sql.identifier('foo'),
    sql.identifier('bar')
  ]sql`, `)})
`

```

both produce:

```sql
(foo, bar)

```
`assignmentList` and `comparisonPredicate` were removed for a similar reason: both can be expressed using existing methods, e.g.

```js
sql.assignmentList({
  bar: 'baz',
  qux: 'quux'
});

```

becomes:

```js
sql.join([
  sql`${sql.identifier(['bar'])} = ${'baz'}`,
  sql`${sql.identifier(['qux'])} = ${'quux'}`
], sql`, `)

// of, if identifiers are static, then just:

sql.join([
  sql`bar = ${'baz'}`,
  s... (continued)

166 of 249 branches covered (66.67%)

Branch coverage included in aggregate %.

439 of 630 relevant lines covered (69.68%)

16.3 hits per line

Source Files on job 562.2
  • Tree
  • List 0
  • Changed 40
  • Source Changed 9
  • Coverage Changed 40
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Build 542
  • Travis Job 562.2
  • 910177db on github
  • Prev Job for on master (#560.2)
  • Next Job for on master (#563.2)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc