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

gajus / slonik / 562
89%

Build:
DEFAULT BRANCH: master
Ran 19 Sep 2019 06:56PM UTC
Jobs 2
Files 66
Run time 35s
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

pending completion
562

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%)

32.59 hits per line

Jobs
ID Job ID Ran Files Coverage
1 562.1 19 Sep 2019 06:56PM UTC 0
68.83
Travis Job 562.1
2 562.2 19 Sep 2019 06:56PM UTC 0
68.83
Travis Job 562.2
Source Files on build 562
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #562
  • 910177db on github
  • Prev Build on master (#560)
  • Next Build on master (#563)
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