<!DOCTYPE html>
<html lang="en" id="oranda" class="dark">
<head>
<title>sqlweld</title>
<link rel="icon" href="/favicon.ico" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Create SQL files from templates and partials" />
<meta property="og:description" content="Create SQL files from templates and partials" />
<meta property="og:type" content="website" />
<meta property="og:title" content="sqlweld" />
<meta http-equiv="Permissions-Policy" content="interest-cohort=()" />
<link rel="stylesheet" href="/oranda-v0.5.0.css" />
</head>
<body>
<div class="container">
<div class="page-body">
<div class="repo_banner">
<a href="https://github.com/dimfeld/sqlweld">
<div class="github-icon" aria-hidden="true"></div>
Check out our GitHub!
</a>
</div>
<main>
<header>
<h1 class="title">sqlweld</h1>
<nav class="nav">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/artifacts/">Install</a></li>
<li><a href="/changelog/">Changelog</a></li>
</ul>
</nav>
</header>
<div class="artifacts" data-tag="v0.1.5">
<div class="artifact-header target">
<h4>Install v0.1.5</h4>
<div><small class="published-date">Published on Nov 22 2023 at 21:41 UTC</small></div>
<ul class="arches">
<li class="arch hidden" data-arch="aarch64-apple-darwin">
<ul class="tabs">
<li class="install-tab" data-id="0" data-triple="aarch64-apple-darwin">
shell
</li>
<li class="install-tab" data-id="3" data-triple="aarch64-apple-darwin">
homebrew
</li>
<li class="install-tab" data-id="2" data-triple="aarch64-apple-darwin">
npm
</li>
<li class="install-tab" data-id="4" data-triple="aarch64-apple-darwin">
tarball
</li>
</ul>
<ul class="contents">
<li data-id="0" data-triple="aarch64-apple-darwin" class="install-content">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">curl</span><span style="color:#89ddff;"> --</span><span style="color:#f78c6c;">proto </span><span style="color:#89ddff;">'</span><span style="color:#c3e88d;">=https</span><span style="color:#89ddff;">' --</span><span style="color:#f78c6c;">tlsv1</span><span style="color:#82aaff;">.2</span><span style="color:#89ddff;"> -</span><span style="color:#f78c6c;">LsSf</span><span style="color:#82aaff;"> https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh </span><span style="color:#89ddff;">| </span><span style="color:#82aaff;">sh</span></pre>
<button class="button copy-clipboard-button primary" data-copy="curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh | sh">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
<a class="button primary" href="/sqlweld-installer.sh.txt">Source</a>
</div>
</li>
<li data-id="3" data-triple="aarch64-apple-darwin" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">brew install dimfeld/homebrew-tap/sqlweld</span></pre>
<button class="button copy-clipboard-button primary" data-copy="brew install dimfeld/homebrew-tap/sqlweld">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="2" data-triple="aarch64-apple-darwin" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">npm install sqlweld@0.1.5</span></pre>
<button class="button copy-clipboard-button primary" data-copy="npm install sqlweld@0.1.5">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="4" data-triple="aarch64-apple-darwin" class="install-content hidden">
<div class="download-wrapper">
<a href="https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-aarch64-apple-darwin.tar.gz">
<button class="button primary">
<span>Download</span>
<span class="button-subtitle">sqlweld-aarch64-apple-darwin.tar.gz</span>
</button>
</a>
</div>
</li>
</ul>
</li>
<li class="arch hidden" data-arch="x86_64-apple-darwin">
<ul class="tabs">
<li class="install-tab" data-id="0" data-triple="x86_64-apple-darwin">
shell
</li>
<li class="install-tab" data-id="3" data-triple="x86_64-apple-darwin">
homebrew
</li>
<li class="install-tab" data-id="2" data-triple="x86_64-apple-darwin">
npm
</li>
<li class="install-tab" data-id="5" data-triple="x86_64-apple-darwin">
tarball
</li>
</ul>
<ul class="contents">
<li data-id="0" data-triple="x86_64-apple-darwin" class="install-content">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">curl</span><span style="color:#89ddff;"> --</span><span style="color:#f78c6c;">proto </span><span style="color:#89ddff;">'</span><span style="color:#c3e88d;">=https</span><span style="color:#89ddff;">' --</span><span style="color:#f78c6c;">tlsv1</span><span style="color:#82aaff;">.2</span><span style="color:#89ddff;"> -</span><span style="color:#f78c6c;">LsSf</span><span style="color:#82aaff;"> https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh </span><span style="color:#89ddff;">| </span><span style="color:#82aaff;">sh</span></pre>
<button class="button copy-clipboard-button primary" data-copy="curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh | sh">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
<a class="button primary" href="/sqlweld-installer.sh.txt">Source</a>
</div>
</li>
<li data-id="3" data-triple="x86_64-apple-darwin" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">brew install dimfeld/homebrew-tap/sqlweld</span></pre>
<button class="button copy-clipboard-button primary" data-copy="brew install dimfeld/homebrew-tap/sqlweld">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="2" data-triple="x86_64-apple-darwin" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">npm install sqlweld@0.1.5</span></pre>
<button class="button copy-clipboard-button primary" data-copy="npm install sqlweld@0.1.5">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="5" data-triple="x86_64-apple-darwin" class="install-content hidden">
<div class="download-wrapper">
<a href="https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-x86_64-apple-darwin.tar.gz">
<button class="button primary">
<span>Download</span>
<span class="button-subtitle">sqlweld-x86_64-apple-darwin.tar.gz</span>
</button>
</a>
</div>
</li>
</ul>
</li>
<li class="arch hidden" data-arch="x86_64-pc-windows-msvc">
<ul class="tabs">
<li class="install-tab" data-id="1" data-triple="x86_64-pc-windows-msvc">
powershell
</li>
<li class="install-tab" data-id="2" data-triple="x86_64-pc-windows-msvc">
npm
</li>
<li class="install-tab" data-id="6" data-triple="x86_64-pc-windows-msvc">
tarball
</li>
</ul>
<ul class="contents">
<li data-id="1" data-triple="x86_64-pc-windows-msvc" class="install-content">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">irm https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.ps1 </span><span style="color:#89ddff;">| </span><span style="color:#82aaff;">iex</span></pre>
<button class="button copy-clipboard-button primary" data-copy="irm https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.ps1 | iex">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
<a class="button primary" href="/sqlweld-installer.ps1.txt">Source</a>
</div>
</li>
<li data-id="2" data-triple="x86_64-pc-windows-msvc" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">npm install sqlweld@0.1.5</span></pre>
<button class="button copy-clipboard-button primary" data-copy="npm install sqlweld@0.1.5">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="6" data-triple="x86_64-pc-windows-msvc" class="install-content hidden">
<div class="download-wrapper">
<a href="https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-x86_64-pc-windows-msvc.tar.gz">
<button class="button primary">
<span>Download</span>
<span class="button-subtitle">sqlweld-x86_64-pc-windows-msvc.tar.gz</span>
</button>
</a>
</div>
</li>
</ul>
</li>
<li class="arch hidden" data-arch="x86_64-unknown-linux-gnu">
<ul class="tabs">
<li class="install-tab" data-id="0" data-triple="x86_64-unknown-linux-gnu">
shell
</li>
<li class="install-tab" data-id="2" data-triple="x86_64-unknown-linux-gnu">
npm
</li>
<li class="install-tab" data-id="7" data-triple="x86_64-unknown-linux-gnu">
tarball
</li>
</ul>
<ul class="contents">
<li data-id="0" data-triple="x86_64-unknown-linux-gnu" class="install-content">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">curl</span><span style="color:#89ddff;"> --</span><span style="color:#f78c6c;">proto </span><span style="color:#89ddff;">'</span><span style="color:#c3e88d;">=https</span><span style="color:#89ddff;">' --</span><span style="color:#f78c6c;">tlsv1</span><span style="color:#82aaff;">.2</span><span style="color:#89ddff;"> -</span><span style="color:#f78c6c;">LsSf</span><span style="color:#82aaff;"> https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh </span><span style="color:#89ddff;">| </span><span style="color:#82aaff;">sh</span></pre>
<button class="button copy-clipboard-button primary" data-copy="curl --proto '=https' --tlsv1.2 -LsSf https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-installer.sh | sh">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
<a class="button primary" href="/sqlweld-installer.sh.txt">Source</a>
</div>
</li>
<li data-id="2" data-triple="x86_64-unknown-linux-gnu" class="install-content hidden">
<div class="install-code-wrapper">
<pre style="background-color:#263238;">
<span style="color:#82aaff;">npm install sqlweld@0.1.5</span></pre>
<button class="button copy-clipboard-button primary" data-copy="npm install sqlweld@0.1.5">
<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 20 20' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'><path d='M8 2a1 1 0 000 2h2a1 1 0 100-2H8z'></path><path d='M3 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v6h-4.586l1.293-1.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L10.414 13H15v3a2 2 0 01-2 2H5a2 2 0 01-2-2V5zM15 11h2a1 1 0 110 2h-2v-2z'></path></svg>
</button>
</div>
</li>
<li data-id="7" data-triple="x86_64-unknown-linux-gnu" class="install-content hidden">
<div class="download-wrapper">
<a href="https://github.com/dimfeld/sqlweld/releases/download/v0.1.5/sqlweld-x86_64-unknown-linux-gnu.tar.gz">
<button class="button primary">
<span>Download</span>
<span class="button-subtitle">sqlweld-x86_64-unknown-linux-gnu.tar.gz</span>
</button>
</a>
</div>
</li>
</ul>
</li>
</ul>
</div>
<div class="no-autodetect hidden">
<span class="no-autodetect-details">We weren't able to detect your OS.</span>
</div>
<noscript>
<a href="/artifacts/">View all installation options</a>
</noscript>
<div class="mac-switch hidden">This project doesn't offer Apple Silicon downloads, but you can run Intel macOS binaries via Rosetta 2.</div>
<div class="bottom-options ">
<a href="/artifacts/" class="backup-download primary">View all installation options</a>
<div class="arch-select hidden">
<select id="install-arch-select">
<option disabled="true" selected="true" value=""></option>
<option value="x86_64-unknown-linux-gnu">Linux x64</option>
<option value="aarch64-apple-darwin">macOS Apple Silicon</option>
<option value="x86_64-apple-darwin">macOS Intel</option>
<option value="x86_64-pc-windows-msvc">Windows x64</option>
</select>
</div>
</div>
</div>
<a href="/artifacts/" class="button mobile-download primary">View all installation options</a>
<h1>sqlweld</h1>
<p>sqlweld is a CLI tool designed to help manage large libraries of SQL statements that need to reuse the same SQL clauses.</p>
<ul>
<li>Permissions checks often look very similar between queries, and updating these clauses is both tedious and a potential
source of security bugs.</li>
<li>Some queries need a number of slight variations, and while they can be formatted at runtime, this loses the benefits
that come from your queries being statically defined, especially with tools that do compile-time checking like
<a href="https://github.com/launchbadge/sqlx" rel="noopener noreferrer">sqlx</a>.</li>
</ul>
<p>sqlweld is designed to help solve these problems. Query files are Liquid templates ending in the
<code>.sql.liquid</code> extension, and partials end with <code>.partial.sql.liquid</code>. The tool will render a <code>.sql</code> file for each
non-partial template it finds.</p>
<p>sqlweld is also a Rust library and can used from a <code>build.rs</code> file. By setting the <code>print_rerun_if_changed</code> option,
it will automatically print the appropriate statements to rerun if the queries change.</p>
<h1>Installation</h1>
<p>Check the <a href="https://github.com/dimfeld/sqlweld/releases" rel="noopener noreferrer">releases page</a> for Homebrew, npm, curl, and other options. Of course, <code>cargo install sqlweld</code> also works if you already have Rust installed.</p>
<h1>Watch Mode</h1>
<p>Watch mode is not directly supported yet. Until it is, a tool such as <a href="https://watchexec.github.io/" rel="noopener noreferrer">watchexec</a> can
accomplish the same functionality.</p>
<pre style="background-color:#263238;"><span style="color:#82aaff;">watchexec</span><span style="color:#89ddff;"> --</span><span style="color:#f78c6c;">exts</span><span style="color:#82aaff;"> liquid</span><span style="color:#89ddff;"> --</span><span style="color:#82aaff;"> sqlweld -v
</span></pre>
<h1>Example</h1>
<p>This example shows a simple use of the tool, with two queries that share a permissions check partial.</p>
<h2>Input</h2>
<h3>get_some_objects.sql.liquid</h3>
<pre style="background-color:#263238;"><span style="color:#eeffff;">SELECT * FROM some_objects
</span><span style="color:#eeffff;">WHERE id=$[obj_id] AND team = $[team_id]
</span><span style="color:#eeffff;">AND {% render 'perm_check', table: "'some_objects'" %}
</span></pre>
<h3>update_some_objects.sql.liquid</h3>
<pre style="background-color:#263238;"><span style="color:#eeffff;">UPDATE some_objects
</span><span style="color:#eeffff;">SET value = 'a'
</span><span style="color:#eeffff;">WHERE id=$[obj_id] AND team = $[team_id]
</span><span style="color:#eeffff;">AND {% render 'perm_check', action: "'write'", table: "'some_objects'" %}
</span></pre>
<h3>perm_check.partial.sql.liquid</h3>
<pre style="background-color:#263238;"><span style="color:#eeffff;">{%- unless user %}{% assign user = "$[user_id]" %}{% endunless -%}
</span><span style="color:#eeffff;">{%- unless team %}{% assign team = "$[team_id]" %}{% endunless -%}
</span><span style="color:#eeffff;">{%- unless action %}{% assign action = "'read'" %}{% endunless -%}
</span><span style="color:#eeffff;">
</span><span style="color:#eeffff;">EXISTS (
</span><span style="color:#eeffff;"> SELECT 1
</span><span style="color:#eeffff;"> FROM permissions
</span><span style="color:#eeffff;"> WHERE user_id = {{ user }}
</span><span style="color:#eeffff;"> AND team_id = {{ team }}
</span><span style="color:#eeffff;"> AND action = {{ action }}
</span><span style="color:#eeffff;"> AND object_type = {{table}}
</span><span style="color:#eeffff;">)
</span></pre>
<h2>Output</h2>
<h3>get_some_objects.sql</h3>
<pre style="background-color:#263238;"><span style="color:#c792ea;">SELECT </span><span style="color:#89ddff;">* </span><span style="color:#c792ea;">FROM</span><span style="color:#eeffff;"> some_objects
</span><span style="color:#c792ea;">WHERE</span><span style="color:#eeffff;"> id</span><span style="color:#89ddff;">=</span><span style="color:#eeffff;">$[obj_id] </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> team </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[team_id]
</span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> EXISTS (
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">SELECT </span><span style="color:#f78c6c;">1
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">FROM</span><span style="color:#eeffff;"> permissions
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">WHERE</span><span style="color:#eeffff;"> user_id </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[user_id]
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> team_id </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[team_id]
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> action </span><span style="color:#89ddff;">= '</span><span style="color:#c3e88d;">read</span><span style="color:#89ddff;">'
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> object_type </span><span style="color:#89ddff;">= '</span><span style="color:#c3e88d;">some_objects</span><span style="color:#89ddff;">'
</span><span style="color:#eeffff;">)
</span></pre>
<h3>update_some_objects.sql</h3>
<pre style="background-color:#263238;"><span style="color:#c792ea;">UPDATE</span><span style="color:#eeffff;"> some_objects
</span><span style="color:#c792ea;">SET</span><span style="color:#eeffff;"> value </span><span style="color:#89ddff;">= '</span><span style="color:#c3e88d;">a</span><span style="color:#89ddff;">'
</span><span style="color:#c792ea;">WHERE</span><span style="color:#eeffff;"> id</span><span style="color:#89ddff;">=</span><span style="color:#eeffff;">$[obj_id] </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> team </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[team_id]
</span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> EXISTS (
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">SELECT </span><span style="color:#f78c6c;">1
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">FROM</span><span style="color:#eeffff;"> permissions
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">WHERE</span><span style="color:#eeffff;"> user_id </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[user_id]
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> team_id </span><span style="color:#89ddff;">=</span><span style="color:#eeffff;"> $[team_id]
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> action </span><span style="color:#89ddff;">= '</span><span style="color:#c3e88d;">write</span><span style="color:#89ddff;">'
</span><span style="color:#eeffff;"> </span><span style="color:#c792ea;">AND</span><span style="color:#eeffff;"> object_type </span><span style="color:#89ddff;">= '</span><span style="color:#c3e88d;">some_objects</span><span style="color:#89ddff;">'
</span><span style="color:#eeffff;">)
</span></pre>
</main>
</div>
<footer>
<a href="https://github.com/dimfeld/sqlweld"><div class="github-icon" aria-hidden="true"></div></a>
<span>
sqlweld, MIT OR Apache-2.0
</span>
</footer>
</div>
<script src="/artifacts.js"></script>
</body>
</html>