{"id":15390284,"url":"https://github.com/gajus/slonik-sql-tag-raw","last_synced_at":"2025-04-15T06:13:02.891Z","repository":{"id":43477858,"uuid":"219605198","full_name":"gajus/slonik-sql-tag-raw","owner":"gajus","description":"Slonik SQL tag for constructing dynamic queries.","archived":false,"fork":false,"pushed_at":"2024-05-07T18:30:16.000Z","size":1762,"stargazers_count":17,"open_issues_count":9,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-15T06:12:57.202Z","etag":null,"topics":["slonik","sql","tag"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gajus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-04T22:02:48.000Z","updated_at":"2025-04-09T10:14:59.000Z","dependencies_parsed_at":"2024-05-07T19:49:47.087Z","dependency_job_id":null,"html_url":"https://github.com/gajus/slonik-sql-tag-raw","commit_stats":{"total_commits":33,"total_committers":5,"mean_commits":6.6,"dds":0.3939393939393939,"last_synced_commit":"1f9be3bd4db4d312017f4b13c87c9b4905394313"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fslonik-sql-tag-raw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fslonik-sql-tag-raw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fslonik-sql-tag-raw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fslonik-sql-tag-raw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gajus","download_url":"https://codeload.github.com/gajus/slonik-sql-tag-raw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016638,"owners_count":21198833,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["slonik","sql","tag"],"created_at":"2024-10-01T15:05:13.825Z","updated_at":"2025-04-15T06:13:02.865Z","avatar_url":"https://github.com/gajus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slonik-sql-tag-raw\n\n[![Travis build status](http://img.shields.io/travis/gajus/slonik-sql-tag-raw/master.svg?style=flat-square)](https://app.travis-ci.com/github/gajus/slonik-sql-tag-raw)\n[![Coveralls](https://img.shields.io/coveralls/gajus/slonik-sql-tag-raw.svg?style=flat-square)](https://coveralls.io/github/gajus/slonik-sql-tag-raw)\n[![NPM version](http://img.shields.io/npm/v/slonik-sql-tag-raw.svg?style=flat-square)](https://www.npmjs.org/package/slonik-sql-tag-raw)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social\u0026label=Follow)](https://twitter.com/kuizinas)\n\n[Slonik](https://github.com/gajus/slonik) SQL tag for constructing dynamic queries.\n\n\u003e [!WARNING]\n\u003e Deprecated in favor of https://github.com/gajus/slonik monorepo.\n\n## Warning\n\nThere are no known use cases for generating queries using `raw` that aren't covered by nesting bound `sql` expressions or by one of the other existing [query building methods](#slonik-query-building). `raw` exists only as a mechanism to execute externally stored _static_ queries (e.g. queries stored in files).\n\n## Usage\n\n```js\nimport {\n  raw,\n} from 'slonik-sql-tag-raw';\n\n```\n\n### `raw`\n\n```js\n(\n  sql: string,\n  values?: $ReadOnlyArray\u003cPrimitiveValueExpressionType\u003e\n) =\u003e RawSqlTokenType;\n\n```\n\nRaw/ dynamic SQL can be inlined using `raw`, e.g.\n\n```js\nsql`\n  SELECT 1\n  FROM ${raw('\"bar\"')}\n`;\n\n```\n\nProduces:\n\n```js\n{\n  sql: 'SELECT 1 FROM \"bar\"',\n  values: []\n}\n\n```\n\nThe second parameter of the `raw` can be used to bind [positional parameter](https://www.postgresql.org/docs/current/sql-expressions.html#SQL-EXPRESSIONS-PARAMETERS-POSITIONAL) values, e.g.\n\n```js\nsql`\n  SELECT ${raw('$1', [1])}\n`;\n\n```\n\nProduces:\n\n```js\n{\n  sql: 'SELECT $1',\n  values: [\n    1\n  ]\n}\n\n```\n\n#### Named parameters\n\n`raw` supports named parameters, e.g.\n\n```js\nsql`\n  SELECT ${raw(':foo, :bar', {bar: 'BAR', foo: 'FOO'})}\n`;\n\n```\n\nProduces:\n\n```js\n{\n  sql: 'SELECT $1, $2',\n  values: [\n    'FOO',\n    'BAR'\n  ]\n}\n\n```\n\nNamed parameters are matched using `/[\\s,(]:([a-z_]+)/g` regex.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fslonik-sql-tag-raw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgajus%2Fslonik-sql-tag-raw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fslonik-sql-tag-raw/lists"}