Skip to content

Commit 67d1c76

Browse files
authored
docs: document how to enable/disable random PK generation (#933)
Document how to enable/disable randomly generated primary key values.
1 parent 0079e74 commit 67d1c76

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ configured:
140140
}
141141
}
142142
143+
Configuring primary key generation
144+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145+
146+
The Spanner Django engine by default uses random int64 values that are generated
147+
by the client as primary key values. This default is applied to all databases that are
148+
configured, including databases that use a different engine than Spanner. You can
149+
disable this behavior with the RANDOM_ID_GENERATION_ENABLED setting:
150+
151+
.. code:: python
152+
153+
DATABASES = {
154+
'default': {
155+
'ENGINE': 'django_spanner',
156+
'PROJECT': '$PROJECT',
157+
'INSTANCE': '$INSTANCE',
158+
'NAME': '$DATABASE',
159+
'RANDOM_ID_GENERATION_ENABLED': false,
160+
}
161+
}
162+
163+
164+
143165
Transaction support in autocommit mode
144166
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145167

0 commit comments

Comments
 (0)