Skip to content

DaredevilOSS/sqlc-gen-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI

sqlc-gen-ruby

Why I didn't use Ruby to generate Ruby in here.

Usage

Options Documentation

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.

Configuration

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

Next features

  1. Supporting sqlite engine, utilizing sqlite3 gem
  2. Adding type support to generated code by generating .rbs files

Contributing

Local plugin development

Prerequisites

make sure that the following applications are installed and exposed in your path

Follow the instructions in each of these:

Protobuf

SQLC protobuf are defined in sqlc-dev/sqlc repository. Generating Ruby code from protocol buffer files:

rake protobuf_generate

Generating code

SQLC utilizes our process / WASM plugin to generate code

rake sqlc_generate_process
rake sqlc_generate_wasm

Testing generated code

Testing the SQLC generated code via a predefined flow:

rake test_process_plugin
rake test_wasm_plugin

Release flow

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

Version bumping (built on tags)

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 with v[major].[minor]+1.0
  • Bump major version by adding [major] to your commit message resulting in a new tag with v[major]+1.0.0

Release structure

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