Skip to content
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

Update some docs for 2.0 #4438

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 0 additions & 157 deletions docs/android_sqlite/upgrading.md

This file was deleted.

10 changes: 10 additions & 0 deletions docs/common/custom_column_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,13 @@ val queryWrapper: Database = Database(
)
)
```

## Value types

SQLDelight can generate a value type for a column which wraps the underlying database type if requested:

```sql
CREATE TABLE hockeyPlayer (
id INT AS VALUE
);
```
25 changes: 25 additions & 0 deletions docs/common/types_server_migrations.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## Optimistic Locking

If you specify a column as a `LOCK`, it would have a value type generated for it, and also require
that `UPDATE` statements correctly use the lock to perform updates.

```sql
CREATE TABLE hockeyPlayer(
id INT AS VALUE,
version_number INT AS LOCK,
nmae VARCHAR(8)
);

-- This will fail (and the IDE plugin will suggest rewriting to the below)
updateName:
UPDATE hockeyPlayer
SET name = ?;

-- This will pass compilation
updateNamePassing:
UPDATE hockeyPlayer
SET name = ?
version_number = :version_number + 1
WHERE version_number = :version_number;
```

## Custom Types in Migrations

If migrations are the schema's source of truth, you can also specify
Expand Down
15 changes: 8 additions & 7 deletions docs/jvm_mysql/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ which specifies the Kotlin type of the column in the generated interface.

```sql
CREATE TABLE some_types (
some_tiny_int TINYINT, -- Retrieved as Int
some_small_int SMALLINT, -- Retrieved as Int
some_bit BIT, -- Retrieved as Boolean
some_tiny_int TINYINT, -- Retrieved as Byte
some_small_int SMALLINT, -- Retrieved as Short
some_medium_int MEDIUMINT, -- Retrieved as Int
some_integer INTEGER, -- Retrieved as Int
some_int INT, -- Retrieved as Int
some_big_int BIGINT, -- Retrieved as Long
some_decimal DECIMAL, -- Retrieved as Double
some_dec DEC, -- Retrieved as Double
some_fixed FIXED, -- Retrieved as Double
some_numeric NUMERIC, -- Retrieved as Double
some_numeric NUMERIC, -- Retrieved as BigDecimal
some_float FLOAT, -- Retrieved as Double
some_real REAL, -- Retrieved as Double
some_double_prec DOUBLE PRECISION, -- Retrieved as Double
some_double DOUBLE, -- Retrieved as Double
some_date DATE, -- Retrieved as String
some_time TIME, -- Retrieved as String
some_datetime DATETIME, -- Retrieved as String
some_timestamp TIMESTAMP, -- Retrieved as String
some_date DATE, -- Retrieved as LocalDate
some_time TIME, -- Retrieved as LocalTime
some_datetime DATETIME, -- Retrieved as LocalDateTime
some_timestamp TIMESTAMP, -- Retrieved as OffsetDateTime
some_year YEAR, -- Retrieved as String
some_char CHAR, -- Retrieved as String
some_varchar VARCHAR(16), -- Retrieved as String
Expand Down
11 changes: 7 additions & 4 deletions docs/jvm_postgresql/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CREATE TABLE some_types (
some_int4 INT4, -- Retrieved as Int
some_bigint BIGINT, -- Retrieved as Long
some_int8 INT8, -- Retrieved as Long
some_numeric NUMERIC, -- Retrieved as Double
some_numeric NUMERIC, -- Retrieved as BigDecimal
some_decimal DECIMAL, -- Retrieved as Double
some_real REAL, -- Retrieved as Double
some_float4 FLOAT4, -- Retrieved as Double
Expand All @@ -30,10 +30,13 @@ CREATE TABLE some_types (
some_char_var CHARACTER VARYING(16), -- Retrieved as String
some_varchar VARCHAR(16), -- Retrieved as String
some_text TEXT, -- Retrieved as String
some_date DATE, -- Retrieved as String
some_time TIME, -- Retrieved as String
some_timestamp TIMESTAMP, -- Retrieved as String
some_date DATE, -- Retrieved as LocalDate
some_time TIME, -- Retrieved as LocalTime
some_timestamp TIMESTAMP, -- Retrieved as LocalDateTime
some_timestamp TIMESTAMPTZ, -- Retrieved as OffsetDateTime
some_json JSON -- Retrieved as String
some_interval INTERVAL -- Retrieved as PGInterval
some_uuid UUID -- Retrieved as UUID
);
```

Expand Down
2 changes: 1 addition & 1 deletion docs/overrides/main.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}

{% block announce %}
SQLDelight 2.0 is now available! See <a href="upgrading-2.0">the docs</a> on migrating.
SQLDelight 2.0 is now available! See <a href="/sqldelight/upgrading-2.0">the docs</a> on migrating.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly, this won't work because our docs are versioned.

e.g. https://cashapp.github.io/sqldelight/**2.0.0-rc02**/upgrading-2.0

Let me check if there's a way to use the version macro in here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, couldn't get it to work.

I added a redirect in our gh-pages setup instead.

{% endblock %}
1 change: 1 addition & 0 deletions docs/upgrading-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,4 @@ dependencies {
* The [`next()`](../2.x/runtime/app.cash.sqldelight.db/-sql-cursor/next) method on the `SqlCursor` interface has also been changed to return a `QueryResult` to enable better cursor support for asynchronous drivers.
* The [`SqlSchema`](../2.x/runtime/app.cash.sqldelight.db/-sql-schema) interface now has a generic `QueryResult` type parameter. This is used to distinguish schema runtimes that were generated for use with asynchronous drivers, which may not be directly compatible with synchronous drivers.
This is only relevant for projects that are simultaneously using synchronous and asynchronous drivers together, like in a multiplatform project that has a JS target. See "[Multiplatform setup with the Web Worker Driver](js_sqlite/multiplatform.md)" for more details.
* The type of `SqlSchema.Version` changed from Int to Long to allow for server environments to leverage timestamps as version. Existing setups can safely cast between from Int and Long, and drivers that require an Int range for versions will crash before database creation for out of bounds versions.
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ nav:
- 'Testing': android_sqlite/testing.md
- 'IntelliJ Plugin': android_sqlite/intellij_plugin.md
- 'Gradle': android_sqlite/gradle.md
- 'Upgrading Pre-1.0': android_sqlite/upgrading.md
- '2.x API':
- 'coroutines-extensions': 2.x/extensions/coroutines-extensions/index.html
- 'rxjava2-extensions': 2.x/extensions/rxjava2-extensions/index.html
Expand Down