
Security News
Oxlint Introduces Type-Aware Linting Preview
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Basic SQL-templating library inspired by https://github.com/krisajenkins/yesql.
You can read more about the rationale for a library like this in Yesql's Readme
gem 'yaasql'
Create a .sql
file to define your queries.
Queries must be identified with a comment line each query a name. This name will become the name of the Ruby method yaasql eventually creates for your query.
You may have multiple queries per file.
-- name: count_examples
SELECT COUNT(*) FROM examples;
require 'yaasql/db'
require 'pg'
class MyDB
DB_CONN = PG.connect(DB_URL)
extend Yaasql::DB
define_queries("./queries.sql", DB_CONN)
end
MyDB.new.count_examples
# => [{"count" => "3"}]
Words with a leading :
in query files will be interpreted as arguments to the query.
-- name: get_example_by_id
SELECT * FROM examples where id = :id limit 1;
-- name: get_examples_by_id
SELECT * FROM examples where id =ANY(:ids);
Arguments can then be provided as a symbol-keyed hash when querying the function:
db = MyDB.new
db.get_example_by_id({id: 1})
# => [{"id" => "1", "name" => "example 1"}]
db.get_examples_by_id({ids: [1,2,3]})
# => [{"id" => "1", "name" => "example 1"}, {"id" => "2", "name" => "example 2"}]
Requires a local postgres server for testing.
bundle install
rake setup # creates the test postgres DB
rake # runs tests
.gem
package.gem
to rubygems.orgbundle exec rake release
.gem
packagebundle exec rake build
bundle exec rake install
=ANY()
where IN (...)
queriesCOPY FROM
/ COPY TO
queries)?
argumentsThe gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that yaasql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.