Skip to content

Commit

Permalink
[SingleStore] Add SingleStore connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguespn committed Oct 1, 2024
1 parent 55231b0 commit c352c09
Show file tree
Hide file tree
Showing 255 changed files with 83,972 additions and 835 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ examples
**/playground
integration-tests/tests/prisma/*/client
integration-tests/tests/prisma/*/drizzle
drizzle-kit/*
7 changes: 1 addition & 6 deletions .github/workflows/release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-typebox
- drizzle-valibot
Expand Down Expand Up @@ -135,12 +136,6 @@ jobs:
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
(
cd integration-tests
pnpm prisma generate --schema tests/prisma/pg/schema.prisma
pnpm prisma generate --schema tests/prisma/mysql/schema.prisma
pnpm prisma generate --schema tests/prisma/sqlite/schema.prisma
)
pnpm build
- name: Run tests
Expand Down
39 changes: 33 additions & 6 deletions .github/workflows/release-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-typebox
- drizzle-valibot
Expand Down Expand Up @@ -138,12 +139,6 @@ jobs:
cd drizzle-orm
pnpm prisma generate --schema src/prisma/schema.prisma
)
(
cd integration-tests
pnpm prisma generate --schema tests/prisma/pg/schema.prisma
pnpm prisma generate --schema tests/prisma/mysql/schema.prisma
pnpm prisma generate --schema tests/prisma/sqlite/schema.prisma
)
pnpm build
- name: Run tests
Expand Down Expand Up @@ -232,3 +227,35 @@ jobs:
} catch (e) {
core.setFailed(e.message);
}
- name: Create GitHub release for KIT package
uses: actions/github-script@v6
if: matrix.package == 'drizzle-kit' && steps.checks.outputs.has_new_release == 'true'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const fs = require("fs");
const path = require("path");
const version = "${{ steps.checks.outputs.version }}";
const changelog = fs.readFileSync("${{ steps.checks.outputs.changelog_path }}", "utf8");
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: `drizzle-kit@${version}`,
name: `drizzle-kit@${version}`,
body: changelog,
});
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
name: `${{ matrix.package }}-${version}-dist.tgz`,
data: fs.readFileSync(path.resolve("${{ matrix.package }}", "package.tgz")),
});
} catch (e) {
core.setFailed(e.message);
}
1 change: 1 addition & 0 deletions .github/workflows/unpublish-release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ jobs:
matrix:
package:
- drizzle-orm
- drizzle-kit
- drizzle-zod
- drizzle-typebox
- drizzle-valibot
Expand Down
162 changes: 137 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,27 @@ There are several ways how you can provide a feedback

---

- [Contributing](#contributing)
- [Submitting bug report](#-submitting-bug-report)
- [Submitting feature request](#-submitting-feature-request)
- [Providing feedback](#-providing-feedback)
- [Contribution guidelines](#-contribution-guidelines)
- [General setup](#-general-setup)
- [Installing node](#-installing-node)
- [Install pnpm](#-install-pnpm)
- [Install docker](#-install-docker)
- [Local project setup](#-local-project-setup)
- [Clone project](#-clone-project)
- [Building project](#-building-project)
- [Build project](#-build-project)
- [Run tests](#-run-tests)
- [Commits and PRs](#-commits-and-prs)
- [Commit guideline](#-commit-guideline)
- [Pre-Contribution setup](#pre-contribution)
- [Installing node](#-installing-node)
- [Install pnpm](#-install-pnpm)
- [Install docker](#-install-docker)
- [Clone project](#-clone-project)
- [Repository Structure](#repo-structure)
- [Build project](#-build-project)
- [Contributing to `drizzle-orm`](#contributing-orm)
- [Project structure](#project-structure-orm)
- [Run tests](#run-tests-orm)
- [Commits and PRs](#commits-and-prs-orm)
- [Commit guideline](#commit-guideline-orm)
- [PR guideline](#pr-guideline-orm)
- [Contributing to `drizzle-kit`](#contributing-kit)
- [Project structure](#project-structure-kit)
- [Run tests](#run-tests-kit)
- [Commits and PRs](#commits-and-prs-kit)
- [Commit guideline](#commit-guideline-kit)
- [PR guideline](#-pr-guideline)

## <a name="general-setup"></a> General setup
## <a name="pre-contribution"></a> Pre-Contribution setup

### <a name="installing-node"></a> Installing node

Expand Down Expand Up @@ -99,14 +101,22 @@ git clone https://github.com/drizzle-team/drizzle-orm.git
cd drizzle-orm
```

## <a name="building-project"></a> Building project
### <a name="repo-structure"></a> Repository Structure

```
Project sctructure
📂 drizzle-orm/ - orm core package with all main logic for each dialect
📂 drizzle-orm/ - core package with all main logic for each dialect
📂 drizzle-kit/ - kit core package with all main logic and tests for each dialect
📂 changelogs/ - all changelogs for drizzle-orm module
📂 drizzle-typebox/ - all the code related to drizzle+typebox extension
📂 drizzle-valibot/ - all the code related to drizzle+valibot extension
📂 drizzle-zod/ - all the code related to drizzle+zod extension
📂 eslint-plugin-drizzle/ - all the code related to drizzle eslint plugin
📂 changelogs/ - all changelogs for drizzle-orm, drizzle-kit, drizzle-typebox, drizzle-zod, drizzle-valibot modules
📂 examples/ - package with Drizzle ORM usage examples
Expand All @@ -119,7 +129,21 @@ Project sctructure

- `"pnpm i && pnpm build"` -> if you run this script from root folder - it will build whole monorepo. Running this script from specific package folder will only build current package

### <a name="run-tests"></a> Run tests
## <a name="contributing-orm"></a> Contributing to `drizzle-orm`

### <a name="project-structure-orm"></a> Project structure

```
Project structure
📂 pg-core, mysql-core, sqlite-core - core packages for each dialect with all the main logic for relation and query builder
📂 sql/ - package containing all expressions and SQL template implementation
All other folders are for specific drivers that Drizzle ORM supports.
```

### <a name="run-tests-orm"></a> Run tests

---
All tests for Drizzle ORM are integration tests, that are simulating real database and different queries and responses from database. Each file in `integration-tests` has a list of different scenarios for different dialect+driver. Each file is creating a docker instance with needed database and running test cases there. Right after all tests were run - docker container with database will be deleted
Expand All @@ -130,9 +154,9 @@ If you have added additional logic to core package - make sure that all tests we
- `"cd integration-tests && pnpm test"` -> will run all tests in integration test folder

## <a name="commits-pr"></a> Commits and PRs
## <a name="commits-and-prs-orm"></a> Commits and PRs

### <a name="commit-guideline"></a> Commit guideline
### <a name="commit-guideline-orm"></a> Commit guideline

---

Expand Down Expand Up @@ -160,7 +184,7 @@ In specific case, groupBy was responding with unreadable error
> **Warning**:
> All commits should be signed, before submitting PR. Please check detailed info on [how to sign commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
### <a name="pr-guideline"></a> PR guideline
### <a name="pr-guideline-orm"></a> PR guideline

---

Expand All @@ -183,3 +207,91 @@ Example
- Tests on bugs, that was fixed;

To understand how test should be created and run - please check [Run tests](#-run-tests) section


## <a name="contributing-kit"></a> Contributing to `drizzle-kit`

### <a name="project-structure-kit"></a> Project structure

```
📂 cli/
|
| -> 📄 schema.ts - all the commands defined using brocli
|
| -> 📂 commands - all the business logic for drizzle-kit commands
📂 extensions/ - all the extension helpers for databases
📂 serialaizer/ - all the necessary logic to read from the Drizzle ORM schema and convert it to a common JSON format, as well as the logic to introspect all tables, types, and other database elements and convert them to a common JSON format
📄 introspect-pg.ts, introspect-mysql.ts, introspect-sqlite.ts - these files are responsible for mapping JSON snapshots to TypeScript files during introspect commands
📄 snapshotsDiffer.ts - this file handles the mapping from JSON snapshot format to JSON statement objects.
📄 jsonStatements.ts - this file defines JSON statement types, interfaces, and helper functions.
📄 sqlgenerator.ts - this file converts JSON statements to SQL strings.
```

### <a name="run-tests-kit"></a> Run tests

---
All tests for Drizzle Kit are integration tests, that are simulating real database and different queries and responses from database. Each file in `drizzle-kit/tests` has a list of different scenarios for different commands. Each MySQL file is creating a docker instance with needed database and running test cases there. Right after all tests were run - docker container with database will be deleted. For PostgreSQL we are using PgLite and for SQLite we are using SQLite files.

If you are in the root of repo:

- `"cd drizzle-kit && pnpm test"` -> will run all tests

## <a name="commits-and-prs-kit"></a> Commits and PRs

### <a name="commit-guideline-kit"></a> Commit guideline

---

We have specific rules on how commit messages should be structured.

It's important to make sure your commit messages are clear, concise, and informative to make it easier for others to understand the changes you are making

Commit message pattern

```
<subject>
<BLANK LINE>
<body>
```

Example

```
Add groupBy error message
In specific case, groupBy was responding with unreadable error
...
```

> **Warning**:
> All commits should be signed, before submitting PR. Please check detailed info on [how to sign commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification)
### <a name="pr-guideline-kit"></a> PR guideline

---

1. PR should be created with specific name pattern

```
[<Dialect name>-kit]: <subject>
```

Example

```
[Pg-kit] Add PostGIS extension support
```

2. PR should contain detailed description with everything, that was changed

3. Each PR should contain
- Tests on feature, that was created;
- Tests on bugs, that was fixed;

To understand how test should be created and run - please check [Run tests](#run-tests) section
2 changes: 2 additions & 0 deletions changelogs/drizzle-kit/0.23.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fixed a bug in PostgreSQL with push and introspect where the `schemaFilter` object was passed. It was detecting enums even in schemas that were not defined in the schemaFilter.
- Fixed the `drizzle-kit up` command to work as expected, starting from the sequences release.
24 changes: 24 additions & 0 deletions changelogs/drizzle-kit/0.24.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Breaking changes (for SQLite users)

#### Fixed [Composite primary key order is not consistent](https://github.com/drizzle-team/drizzle-kit-mirror/issues/342) by removing `sort` in SQLite and to be consistant with the same logic in PostgreSQL and MySQL

The issue that may arise for SQLite users with any driver using composite primary keys is that the order in the database may differ from the Drizzle schema.

- If you are using `push`, you **MAY** be prompted to update your table with a new order of columns in the composite primary key. You will need to either change it manually in the database or push the changes, but this may lead to data loss, etc.

- If you are using `generate`, you **MAY** also be prompted to update your table with a new order of columns in the composite primary key. You can either keep that migration or skip it by emptying the SQL migration file.

If nothing works for you and you are blocked, please reach out to me @AndriiSherman. I will try to help you!


## Bug fixes

- [[BUG] When using double type columns, import is not inserted](https://github.com/drizzle-team/drizzle-kit-mirror/issues/403) - thanks @Karibash
- [[BUG] A number value is specified as the default for a column of type char](https://github.com/drizzle-team/drizzle-kit-mirror/issues/404) - thanks @Karibash
- [[BUG]: Array default in migrations are wrong](https://github.com/drizzle-team/drizzle-orm/issues/2621) - thanks @L-Mario564
- [[FEATURE]: Simpler default array fields](https://github.com/drizzle-team/drizzle-orm/issues/2709) - thanks @L-Mario564
- [[BUG]: drizzle-kit generate succeeds but generates invalid SQL for default([]) - Postgres](https://github.com/drizzle-team/drizzle-orm/issues/2432) - thanks @L-Mario564
- [[BUG]: Incorrect type for array column default value](https://github.com/drizzle-team/drizzle-orm/issues/2334) - thanks @L-Mario564
- [[BUG]: error: column is of type integer[] but default expression is of type integer](https://github.com/drizzle-team/drizzle-orm/issues/2224) - thanks @L-Mario564
- [[BUG]: Default value in array generating wrong migration file](https://github.com/drizzle-team/drizzle-orm/issues/1003) - thanks @L-Mario564
- [[BUG]: enum as array, not possible?](https://github.com/drizzle-team/drizzle-orm/issues/1564) - thanks @L-Mario564
32 changes: 32 additions & 0 deletions changelogs/drizzle-kit/0.24.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Bug fixes

> Big thanks to @L-Mario564 for his [PR](https://github.com/drizzle-team/drizzle-orm/pull/2804). It conflicted in most cases with a PR that was merged, but we incorporated some of his logic. Merging it would have caused more problems and taken more time to resolve, so we just took a few things from his PR, like removing "::<type>" mappings in introspect and some array type default handlers
### What was fixed

1. The Drizzle Kit CLI was not working properly for the `introspect` command.
2. Added the ability to use column names with special characters for all dialects.
3. Included PostgreSQL sequences in the introspection process.
4. Reworked array type introspection and added all test cases.
5. Fixed all (we hope) default issues in PostgreSQL, where `::<type>` was included in the introspected output.
6. `preserve` casing option was broken

### Tickets that were closed

- [[BUG]: invalid schema generation with drizzle-kit introspect:pg](https://github.com/drizzle-team/drizzle-orm/issues/1210)
- [[BUG][mysql introspection]: TS error when introspect column including colon](https://github.com/drizzle-team/drizzle-orm/issues/1928)
- [[BUG]: Unhandled defaults when introspecting postgres db](https://github.com/drizzle-team/drizzle-orm/issues/1625)
- [[BUG]: PostgreSQL Enum Naming and Schema Typing Issue](https://github.com/drizzle-team/drizzle-orm/issues/2315)
- [[BUG]: drizzle-kit instrospect command generates syntax error on varchar column types](https://github.com/drizzle-team/drizzle-orm/issues/2714)
- [[BUG]: Introspecting varchar[] type produces syntactically invalid schema.ts](https://github.com/drizzle-team/drizzle-orm/issues/1633)
- [[BUG]: introspect:pg column not using generated enum name](https://github.com/drizzle-team/drizzle-orm/issues/1648)
- [[BUG]: drizzle-kit introspect casing "preserve" config not working](https://github.com/drizzle-team/drizzle-orm/issues/2773)
- [[BUG]: drizzle-kit introspect fails on required param that is defined](https://github.com/drizzle-team/drizzle-orm/issues/2719)
- [[BUG]: Error when running npx drizzle-kit introspect: "Expected object, received string"](https://github.com/drizzle-team/drizzle-orm/issues/2657)
- [[BUG]: Missing index names when running introspect command [MYSQL]](https://github.com/drizzle-team/drizzle-orm/issues/2525)
- [[BUG]: drizzle-kit introspect TypeError: Cannot read properties of undefined (reading 'toLowerCase')](https://github.com/drizzle-team/drizzle-orm/issues/2338)
- [[BUG]: Wrong column name when using PgEnum.array()](https://github.com/drizzle-team/drizzle-orm/issues/2100)
- [[BUG]: Incorrect Schema Generated when introspecting extisting pg database](https://github.com/drizzle-team/drizzle-orm/issues/1985)
- [[⚠️🐞BUG]: index() missing argument after introspection, causes tsc error that fails the build](https://github.com/drizzle-team/drizzle-orm/issues/1870)
- [[BUG]: drizzle-kit introspect small errors](https://github.com/drizzle-team/drizzle-orm/issues/1738)
- [[BUG]: Missing bigint import in drizzle-kit introspect](https://github.com/drizzle-team/drizzle-orm/issues/1020)
24 changes: 24 additions & 0 deletions changelogs/drizzle-kit/0.24.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## New Features

### 🎉 Support for `pglite` driver

You can now use pglite with all drizzle-kit commands, including Drizzle Studio!

```ts
import { defineConfig } from "drizzle-kit";

export default defineConfig({
dialect: "postgresql",
driver: "pglite",
schema: "./schema.ts",
dbCredentials: {
url: "local-pg.db",
},
verbose: true,
strict: true,
});
```

## Bug fixes

- mysql-kit: fix GENERATED ALWAYS AS ... NOT NULL - [#2824](https://github.com/drizzle-team/drizzle-orm/pull/2824)
4 changes: 4 additions & 0 deletions changelogs/drizzle-orm/0.32.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Fix AWS Data API type hints bugs in RQB
- Fix set transactions in MySQL bug - thanks @roguesherlock
- Add forwaring dependencies within useLiveQuery, fixes [#2651](https://github.com/drizzle-team/drizzle-orm/issues/2651) - thanks @anstapol
- Export additional types from SQLite package, like `AnySQLiteUpdate` - thanks @veloii
Loading

0 comments on commit c352c09

Please sign in to comment.