Comments (2)
@StevenACoffman I came here looking for the same thing.
You can get these annotations by modifying the sqlc-gen-go template in internal/templates/./queryCode.tmpl.
That said, you didn't want to use the database/sql
interface and I was unable to get prashanthpai/sqlcache to work using pgx/pgxpool directly. But that looks like a limitation of prashanthpai/sqlcache
I was able to get this to work by modifying the template in internal/templates/stdlib/queryCode.tmpl
like so:
...
const {{.ConstantName}} = {{$.Q}}-- name: {{.MethodName}} {{.Cmd}}
{{range .Comments}}--{{.}}
{{end -}}
{{escape .SQL}}
{{$.Q}}
...
You can then write your query as:
-- name: ProductByZip :many
-- @cache-ttl 30
-- @cache-max-rows 100
select distinct p.name as product, v.name as vendor from product p
join vendors v on p.vendor = v.id
join vendorsa va on v.id = va.vendor
where va.zip = $1;
Hope this helps.
from sqlc.
@bldrdash Nice!
I filed an issue with jackc/pgx#1935 along the same lines, and the maintainer raised a good point.
The declarative nature of prashanthpai/sqlcache is nice, but the way sqlcache (and sqlmw) is implemented in the SQL driver, it requires a re-parse before deciding to just use the cached version. This makes the performance worse than it needs to be.
If the sqlc generated template Go code decided to attempt to use the cached version, it would not require re-parsing the SQL, so it would perform faster.
from sqlc.
Related Issues (20)
- SQL Pathing is incompatible with Sveltekit Route Params HOT 1
- Support for database table prefixes HOT 2
- Failure to install sqlc@latest HOT 1
- postgresType cases have inconsistent input precedence HOT 1
- Column reference is ambiguous
- PRAGMA queries are not recognised HOT 1
- sqlc.embed(<right_join_table>) should generate NULLable fields in LEFT/RIGHT JOIN HOT 1
- Dynamically fetch the package name for single import strings HOT 1
- Support for Turso (libsql) HOT 1
- SQLite generating code error HOT 1
- Capital letters in table alias causes generation to fail HOT 1
- Add support for COPY command in bulk inserts with lib/pq driver
- NOT NULL is ignored in DOMAIN
- Interface should include WithTx()
- Left joining same table as FROM statement results in unexpected string type rather than a nullable string type HOT 2
- UUID is not correctly overridden HOT 3
- go: expose DBTX inside Queries (via flag) HOT 4
- Typecast for nullable types
- Support generating pointers for nullable enum types (emit_pointers_for_null_types for enums)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlc.