Why I didn't use Ruby to generate Ruby in here.
Option | Possible values | Optional | Info |
---|---|---|---|
driver | values: mysql2 ,pg , sqlite3 |
No | Choosing the driver to use - see here for more details info. |
rubyVersion | default: 3.3 values: 3.1 , 3.2 , 3.3 |
Yes | Determines the Ruby version the generated code should support.. |
generateGemfile | default: false values: false ,true |
Yes | Assists you with the integration of SQLC and Ruby by generating a Gemfile with the needed dependencies. |
generateTypes | default: true values: false ,true |
Yes | Determines whether to generate type signatures in addition to the code. |
version: "2"
plugins:
- name: ruby
wasm:
url: https://github.com/DaredevilOSS/sqlc-gen-ruby/releases/download/${RELEASE_TAG}/sqlc-gen-ruby.wasm
sha256: ${RELEASE_SHA}
sql:
# PostgreSQL Example
- schema: "examples/authors/postgresql/schema.sql"
queries: "examples/authors/postgresql/query.sql"
engine: "postgresql"
codegen:
- plugin: ruby
out: examples/pg
options:
driver: pg
rubyVersion: "3.3"
generateTypes: true
generateGemfile: false
# MySQL Example
- schema: "examples/authors/mysql/schema.sql"
queries: "examples/authors/mysql/query.sql"
engine: "mysql"
codegen:
- plugin: ruby
out: examples/mysql2
options:
driver: mysql2
rubyVersion: "3.3"
generateTypes: true
generateGemfile: false
# Sqlite3 Example
- schema: "examples/authors/sqlite/schema.sql"
queries: "examples/authors/sqlite/query.sql"
engine: "sqlite"
codegen:
- plugin: ruby
out: examples/sqlite3
options:
driver: sqlite3
rubyVersion: "3.3"
generateTypes: true
generateGemfile: false
- Supporting sqlite engine, utilizing sqlite3 gem
- Adding type support to generated code by generating .rbs files
make sure that the following applications are installed and exposed in your path
Follow the instructions in each of these:
- Ruby - Ruby Installation
- Dotnet CLI - Dotnet Installation - use version
.NET 8.0 (latest)
- buf build - Buf Build
- WASM related - WASM libs
SQLC protobuf are defined in sqlc-dev/sqlc repository. Generating Ruby code from protocol buffer files:
rake protobuf_generate
SQLC utilizes our process / WASM plugin to generate code
rake sqlc_generate_process
rake sqlc_generate_wasm
Testing the SQLC generated code via a predefined flow:
rake test_process_plugin
rake test_wasm_plugin
The release flow in this repo follows the semver conventions, building tag as v[major].[minor].[patch]
.
- In order to create a release you need to add
[release]
somewhere in your commit message when merging to master
By default, the release script will bump the patch version., by adding [release]
to your commit message the release script will create a new tag with v[major].[minor].[patch]+1
.
- Bump
minor
version by adding[minor]
to your commit message resulting in a new tag withv[major].[minor]+1.0
- Bump
major
version by adding[major]
to your commit message resulting in a new tag withv[major]+1.0.0
The new created tag will create a draft release with it, in the release there will be the wasm plugin embedded in the release.
Publish the draft