How to use the pg-sql2.blank function in pg-sql2

To help you get started, we’ve selected a few pg-sql2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphile / graphile-engine / packages / graphile-build-pg / src / QueryBuilder.ts View on Github external
([expr, ascending, nullsFirst]) =>
            sql.fragment`${expr} ${
              Number(ascending) ^ Number(flip)
                ? sql.fragment`ASC`
                : sql.fragment`DESC`
            }${
              nullsFirst === true
                ? sql.fragment` NULLS FIRST`
                : nullsFirst === false
                ? sql.fragment` NULLS LAST`
                : sql.blank
            }`
        ),
github graphile / graphile-engine / packages / graphile-build-pg / src / QueryBuilder.ts View on Github external
return this.buildSelectJson({ addNullCase, addNotDistinctFromNullCase });
    }
    const { limit, offset, flip } = this.getFinalLimitAndOffset();
    const fields =
      asJson || asJsonAggregate
        ? sql.fragment`${this.buildSelectJson({
            addNullCase,
            addNotDistinctFromNullCase,
          })} as object`
        : this.buildSelectFields();

    let fragment = sql.fragment`\
select ${useAsterisk ? sql.fragment`${this.getTableAlias()}.*` : fields}
${(this.compiledData.from &&
  sql.fragment`from ${this.compiledData.from[0]} as ${this.getTableAlias()}`) ||
  sql.blank}
${(this.compiledData.join.length && sql.join(this.compiledData.join, " ")) ||
  sql.blank}
where ${this.buildWhereClause(true, true, options)}
${
  this.compiledData.orderBy.length
    ? sql.fragment`order by ${sql.join(
        this.compiledData.orderBy.map(
          ([expr, ascending, nullsFirst]) =>
            sql.fragment`${expr} ${
              Number(ascending) ^ Number(flip)
                ? sql.fragment`ASC`
                : sql.fragment`DESC`
            }${
              nullsFirst === true
                ? sql.fragment` NULLS FIRST`
                : nullsFirst === false

pg-sql2

Generate safe Postgres-compliant SQL with tagged template literals

MIT
Latest version published 2 years ago

Package Health Score

64 / 100
Full package analysis