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
+28-12
Original file line number
Diff line number
Diff line change
@@ -82,19 +82,35 @@ DATABASES = {
82
82
83
83
## Limitations
84
84
85
-
Limitation|Comment|Resolution
86
-
---|---|---
87
-
Lack of DEFAULT for columns|Cloud Spanner doesn't support using DEFAULT for columns thus the use of default values might have to enforced in your controller logic|
88
-
Lack of FOREIGN KEY constraints|Cloud Spanner doesn't support foreign key constraints thus they have to be defined in code
89
-
Lack of sequential and auto-assigned IDs|Cloud Spanner doesn't autogenerate IDs and this integration instead creates UUID4 to avoid [hotspotting](https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key) so you SHOULD NOT rely on IDs being sorted|We generate UUID4s for each AutoField
90
-
Numeric values are saved as FLOAT64|Cloud Spanner doesn't support the NUMERIC type thus we might have precision losses|Decimal and Numeric are translated to FLOAT64. If Cloud Spanner adds NUMERIC in the future, you might need to migrate your columns
91
-
Optimistic transactions when running DDL and other statements|Cloud Spanner CANNOT run DDL (CREATE, DROP, ALTER) in a Transaction and CAN ONLY run them in the [DatabaseAdmin RPC]() so any mixes of DDL and other statements will make prior statements get run, DDL run, then following statements run separately|
92
-
107 unexplored Django tests|We need to run every single test in the Django test suite for 100% certainty|Currently in progress to complete the [211 test cases](https://gist.github.com/odeke-em/d3476b6cb7c3485de6aa29956ed50a75#file-all_tests-txt)
93
-
Table names CANNOT have spaces within them whether back-ticked or not|Cloud Spanner DOEST NOT support tables with spaces in them for example `Entity ID`|Ensure that your table names don't have spaces within them
94
-
Table names CANNOT have punctuation marks and MUST contain valid UTF-8|Cloud Spanner DOEST NOT support punctuation marks e.g. periods ".", question marks "?" in table names|Ensure that your table names don't have punctuation marks
95
-
Lack of stored procedures and triggers|Cloud Spanner DOES NOT support stored procedures nor triggers so if your code relies on them, you might need to move the logic into your application|Not supported
96
-
Lack of VARIANCE, STDDEV database functions|Cloud Spanned doesn't yet implement these functions|
85
+
### `AutoField` generates random IDs
97
86
87
+
Spanner doesn't have a way to auto-generate primary key values. Instead,
88
+
django-spanner monkeypatches `AutoField` to generate a random UUID4. It
89
+
generates a default using `Field`'s `default` option which means `AutoField`s
90
+
will have a value when a model instance is created. For example:
91
+
92
+
```
93
+
>>> ExampleModel()
94
+
>>> ExampleModel.pk
95
+
4229421414948291880
96
+
```
97
+
98
+
To avoid [hotspotting](https://cloud.google.com/spanner/docs/schema-design#uuid_primary_key),
99
+
these IDs are not monotonically increasing. This means that sorting models by
100
+
id isn't guaranteed to return them in the order in which they were created.
0 commit comments