-
Notifications
You must be signed in to change notification settings - Fork 8
sqlite support #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sqlite support #270
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c629851
sqlite
JasonShin 2c2b4b5
fmt
JasonShin b5a7c1c
sqlite tests
JasonShin e42f6c1
fix
JasonShin 9363c29
fix
JasonShin d6c7247
demo github action
JasonShin c6a9a92
fix demo test
JasonShin 4e5bc76
fix
JasonShin d2d8466
update
JasonShin 488a801
update
JasonShin c99571a
Merge branch 'main' into sqlite
JasonShin 727d073
npm i
JasonShin acbc9a2
add sqlx-ts
JasonShin b990300
fix
JasonShin 1d5d64e
fix ci
JasonShin 3b6aca3
fix github action
JasonShin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| name: demo projects | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| demo-test: | ||
| name: Demo project sqlx-ts (${{ matrix.db.name }}) | ||
| if: "!contains(github.event.head_commit.message, 'Release')" | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| BUILD_MODE: release | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| db: | ||
| - name: postgres-16 | ||
| postgres: "16" | ||
| mysql: "" | ||
| - name: postgres-13 | ||
| postgres: "13" | ||
| mysql: "" | ||
| - name: mysql-8 | ||
| postgres: "" | ||
| mysql: "8" | ||
| - name: sqlite | ||
| postgres: "" | ||
| mysql: "" | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install stable Rust toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - uses: Swatinem/rust-cache@v2 | ||
| with: | ||
| save-if: ${{ github.ref == 'refs/heads/main' }} | ||
| cache-provider: "github" | ||
|
|
||
| - name: Build sqlx-ts binary | ||
| run: cargo build --release | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Start database services | ||
| if: matrix.db.postgres != '' || matrix.db.mysql != '' | ||
| run: docker compose -f docker-compose.yml up -d | ||
| env: | ||
| PG_VERSION: ${{ matrix.db.postgres || '16' }} | ||
| MYSQL_VERSION: ${{ matrix.db.mysql || '8' }} | ||
|
|
||
| - name: Wait for databases to be ready | ||
| if: matrix.db.postgres != '' || matrix.db.mysql != '' | ||
| run: | | ||
| echo "Waiting for databases to initialize..." | ||
| sleep 15 | ||
| if [ -n "${{ matrix.db.postgres }}" ]; then | ||
| until docker compose exec -T postgres pg_isready -U postgres 2>/dev/null; do | ||
| echo "Waiting for PostgreSQL..." | ||
| sleep 2 | ||
| done | ||
| echo "PostgreSQL is ready" | ||
| fi | ||
| if [ -n "${{ matrix.db.mysql }}" ]; then | ||
| until docker compose exec -T mysql mysqladmin ping -h localhost --silent 2>/dev/null; do | ||
| echo "Waiting for MySQL..." | ||
| sleep 2 | ||
| done | ||
| echo "MySQL is ready" | ||
| fi | ||
|
|
||
| - name: Create SQLite database | ||
| if: matrix.db.name == 'sqlite' | ||
| working-directory: ./demo | ||
| run: | | ||
| sudo apt-get update && sudo apt-get install -y sqlite3 | ||
| bash ./create-sqlite.sh | ||
|
|
||
| - name: Install demo dependencies | ||
| working-directory: ./demo | ||
| run: npm install | ||
|
|
||
| - name: Generate types (PostgreSQL demos) | ||
| if: matrix.db.postgres != '' | ||
| working-directory: ./demo | ||
| run: | | ||
| ../target/release/sqlx-ts ./pg --config ./.sqlxrc.json -g | ||
| ../target/release/sqlx-ts ./sequelize --config ./.sqlxrc.json -g | ||
|
|
||
| - name: Generate types (MySQL demo) | ||
| if: matrix.db.mysql != '' | ||
| working-directory: ./demo | ||
| run: | | ||
| ../target/release/sqlx-ts ./mysql2 --config ./.sqlxrc.json -g | ||
|
|
||
| - name: Generate types (SQLite demo) | ||
| if: matrix.db.name == 'sqlite' | ||
| working-directory: ./demo | ||
| run: | | ||
| ../target/release/sqlx-ts ./sqlite --config ./.sqlxrc.json -g | ||
|
|
||
| - name: Type-check generated code | ||
| working-directory: ./demo | ||
| run: npm run build |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules | ||
| .idea | ||
| dist | ||
| .DS_Store | ||
| *.db |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "generate_types": { | ||
| "enabled": true, | ||
| "convertToCamelCaseColumnName": true | ||
| }, | ||
| "connections": { | ||
| "default": { | ||
| "DB_TYPE": "postgres", | ||
| "DB_HOST": "127.0.0.1", | ||
| "DB_PORT": 54321, | ||
| "DB_USER": "postgres", | ||
| "DB_PASS": "postgres", | ||
| "DB_NAME": "postgres" | ||
| }, | ||
| "db_mysql": { | ||
| "DB_TYPE": "mysql", | ||
| "DB_HOST": "127.0.0.1", | ||
| "DB_PORT": 33306, | ||
| "DB_USER": "root", | ||
| "DB_NAME": "sqlx-ts" | ||
| }, | ||
| "db_sqlite": { | ||
| "DB_TYPE": "sqlite", | ||
| "DB_NAME": "./sqlite/demo.db" | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # sqlx-ts demo | ||
|
|
||
| Usage examples showing sqlx-ts with different database drivers. | ||
|
|
||
| ## Examples | ||
|
|
||
| - [pg](./pg) - PostgreSQL with `pg` driver | ||
| - [mysql2](./mysql2) - MySQL with `mysql2` driver | ||
| - [sequelize](./sequelize) - PostgreSQL with Sequelize ORM | ||
| - [sqlite](./sqlite) - SQLite with `better-sqlite3` (no Docker needed) | ||
|
|
||
| ## Running locally | ||
|
|
||
| ```bash | ||
| # Start databases (from repo root) | ||
| docker compose up -d | ||
|
|
||
| # Install demo dependencies | ||
| cd demo | ||
| npm install | ||
|
|
||
| # Generate types and type-check | ||
| npm run compile:all | ||
| npm run typecheck | ||
| ``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.