You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-10Lines changed: 24 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,11 @@
3
3
`yo` is a command-line tool to generate Go code for [Google Cloud Spanner](https://cloud.google.com/spanner/),
4
4
forked from [xo](https://github.com/xo/xo):rose:.
5
5
6
-
`yo` uses database schema to generate code by using [Information Schema](https://cloud.google.com/spanner/docs/information-schema). `yo` runs SQL queries against tables in `INFORMATION_SCHEMA` to fetch metadata for a database, and applies the metadata to Go templates to generate code/models to access Cloud Spanner.
6
+
`yo` can generate code from database schema using either DDL files or [Information Schema](https://cloud.google.com/spanner/docs/information-schema).
7
+
8
+
**⚠️ Note: Using Information Schema for code generation is now deprecated due to column ordering issues (see [#154](https://github.com/cloudspannerecosystem/yo/issues/154)). Please use DDL files for reliable code generation instead.**
9
+
10
+
When using Information Schema, `yo` runs SQL queries against tables in `INFORMATION_SCHEMA` to fetch metadata for a database. When using DDL files (recommended), `yo` parses the DDL directly. In both cases, the metadata is applied to Go templates to generate code/models to access Cloud Spanner.
7
11
8
12
Please feel free to report issues and send pull requests, but note that this
9
13
application is not officially supported as part of the Cloud Spanner product.
@@ -24,14 +28,24 @@ go get -u go.mercari.io/yo
24
28
25
29
The following is a quick overview of using `yo` on the command-line:
26
30
31
+
**Recommended: Generate from DDL file**
27
32
```sh
28
33
# change to project directory
29
34
$ cd$GOPATH/src/path/to/project
30
35
31
36
# make an output directory
32
37
$ mkdir -p models
33
38
34
-
# generate code for a schema
39
+
# generate code from DDL file (recommended)
40
+
$ yo generate schema.sql --from-ddl -o models
41
+
```
42
+
43
+
**⚠️ Deprecated: Generate from Information Schema**
44
+
```sh
45
+
# make an output directory
46
+
$ mkdir -p models
47
+
48
+
# generate code from Information Schema (deprecated - see issue #154)
35
49
$ yo $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models
36
50
```
37
51
@@ -47,16 +61,16 @@ Usage:
47
61
yo PROJECT_NAME INSTANCE_NAME DATABASE_NAME [flags]
48
62
49
63
Examples:
50
-
# Generate models from DDL under the models directory
51
-
yo generate schame.sql --from-ddl -o models
52
-
53
-
# Generate models from DDL under the models directory with custom types
54
-
yo generate schame.sql --from-ddl -o models --custom-types-file custom_column_types.yml
55
-
56
-
# Generate models under models directory
64
+
# Generate models from DDL under the models directory (recommended)
65
+
yo generate schema.sql --from-ddl -o models
66
+
67
+
# Generate models from DDL under the models directory with custom types (recommended)
68
+
yo generate schema.sql --from-ddl -o models --custom-types-file custom_column_types.yml
69
+
70
+
# Generate models under models directory (deprecated - see issue #154)
57
71
yo $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models
58
72
59
-
# Generate models under models directory with custom types
73
+
# Generate models under models directory with custom types (deprecated - see issue #154)
60
74
yo $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models --custom-types-file custom_column_types.yml
fmt.Fprintf(os.Stderr, "Warning: Using Information Schema for code generation is deprecated due to column ordering issues (see https://github.com/cloudspannerecosystem/yo/issues/154). Please use DDL files for reliable code generation instead.\n")
Copy file name to clipboardExpand all lines: v2/README.md
+22-8Lines changed: 22 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,11 @@
3
3
`yo` is a command-line tool to generate Go code for [Google Cloud Spanner](https://cloud.google.com/spanner/),
4
4
forked from [xo](https://github.com/xo/xo):rose:.
5
5
6
-
`yo` uses database schema to generate code by using [Information Schema](https://cloud.google.com/spanner/docs/information-schema). `yo` runs SQL queries against tables in `INFORMATION_SCHEMA` to fetch metadata for a database and applies the metadata to Go templates to generate code/models to access Cloud Spanner.
6
+
`yo` can generate code from database schema using either DDL files or [Information Schema](https://cloud.google.com/spanner/docs/information-schema).
7
+
8
+
**⚠️ Note: Using Information Schema for code generation is now deprecated due to column ordering issues (see [#154](https://github.com/cloudspannerecosystem/yo/issues/154)). Please use DDL files for reliable code generation instead.**
9
+
10
+
When using Information Schema, `yo` runs SQL queries against tables in `INFORMATION_SCHEMA` to fetch metadata for a database. When using DDL files (recommended), `yo` parses the DDL directly. In both cases, the metadata is applied to Go templates to generate code/models to access Cloud Spanner.
7
11
8
12
Please feel free to report issues and send pull requests, but note that this
9
13
application is not officially supported as part of the Cloud Spanner product.
@@ -18,14 +22,24 @@ $ go get -u go.mercari.io/yo/v2
18
22
19
23
The following is a quick overview of using `yo` on the command line:
20
24
25
+
**Recommended: Generate from DDL file**
21
26
```sh
22
27
# change to the project directory
23
28
$ cd$GOPATH/src/path/to/project
24
29
25
30
# make an output directory
26
31
$ mkdir -p models
27
32
28
-
# generate code for a schema
33
+
# generate code from DDL file (recommended)
34
+
$ yo generate schema.sql --from-ddl -o models
35
+
```
36
+
37
+
**⚠️ Deprecated: Generate from Information Schema**
38
+
```sh
39
+
# make an output directory
40
+
$ mkdir -p models
41
+
42
+
# generate code from Information Schema (deprecated - see issue #154)
29
43
$ yo generate $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models
30
44
```
31
45
@@ -38,17 +52,17 @@ The `generate` command generates the Go code from DDL.
38
52
#### Examples
39
53
40
54
```sh
41
-
# Generate models from DDL under the models directory
55
+
# Generate models from DDL under the models directory (recommended)
42
56
yo generate schema.sql --from-ddl -o models
43
57
44
-
# Generate models from DDL under the models directory with custom types
45
-
yo generate schema.sql --from-ddl -o models --custom-types-file custom_column_types.yml
58
+
# Generate models from DDL under the models directory with custom types (recommended)
59
+
yo generate schema.sql --from-ddl -o models --config config.yml
46
60
47
-
# Generate models under the models directory
61
+
# Generate models under the models directory (deprecated - see issue #154)
48
62
yo generate $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models
49
63
50
-
# Generate models under the models directory with custom types
51
-
yo generate $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models --custom-types-file custom_column_types.yml
64
+
# Generate models under the models directory with custom types (deprecated - see issue #154)
65
+
yo generate $SPANNER_PROJECT_NAME$SPANNER_INSTANCE_NAME$SPANNER_DATABASE_NAME -o models --config config.yml
returnfmt.Errorf("failed to create spanner loader: %v", err)
150
150
}
151
151
} else {
152
+
fmt.Fprintf(os.Stderr, "Warning: Using Information Schema for code generation is deprecated due to column ordering issues (see https://github.com/cloudspannerecosystem/yo/issues/154). Please use DDL files for reliable code generation instead.\n")
0 commit comments