-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathquery.sql.go
544 lines (486 loc) · 19.5 KB
/
query.sql.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
// Code generated by pggen. DO NOT EDIT.
package composite
import (
"context"
"fmt"
"github.com/jackc/pgconn"
"github.com/jackc/pgtype"
"github.com/jackc/pgx/v4"
)
// Querier is a typesafe Go interface backed by SQL queries.
//
// Methods ending with Batch enqueue a query to run later in a pgx.Batch. After
// calling SendBatch on pgx.Conn, pgxpool.Pool, or pgx.Tx, use the Scan methods
// to parse the results.
type Querier interface {
SearchScreenshots(ctx context.Context, params SearchScreenshotsParams) ([]SearchScreenshotsRow, error)
// SearchScreenshotsBatch enqueues a SearchScreenshots query into batch to be executed
// later by the batch.
SearchScreenshotsBatch(batch genericBatch, params SearchScreenshotsParams)
// SearchScreenshotsScan scans the result of an executed SearchScreenshotsBatch query.
SearchScreenshotsScan(results pgx.BatchResults) ([]SearchScreenshotsRow, error)
SearchScreenshotsOneCol(ctx context.Context, params SearchScreenshotsOneColParams) ([][]Blocks, error)
// SearchScreenshotsOneColBatch enqueues a SearchScreenshotsOneCol query into batch to be executed
// later by the batch.
SearchScreenshotsOneColBatch(batch genericBatch, params SearchScreenshotsOneColParams)
// SearchScreenshotsOneColScan scans the result of an executed SearchScreenshotsOneColBatch query.
SearchScreenshotsOneColScan(results pgx.BatchResults) ([][]Blocks, error)
InsertScreenshotBlocks(ctx context.Context, screenshotID int, body string) (InsertScreenshotBlocksRow, error)
// InsertScreenshotBlocksBatch enqueues a InsertScreenshotBlocks query into batch to be executed
// later by the batch.
InsertScreenshotBlocksBatch(batch genericBatch, screenshotID int, body string)
// InsertScreenshotBlocksScan scans the result of an executed InsertScreenshotBlocksBatch query.
InsertScreenshotBlocksScan(results pgx.BatchResults) (InsertScreenshotBlocksRow, error)
ArraysInput(ctx context.Context, arrays Arrays) (Arrays, error)
// ArraysInputBatch enqueues a ArraysInput query into batch to be executed
// later by the batch.
ArraysInputBatch(batch genericBatch, arrays Arrays)
// ArraysInputScan scans the result of an executed ArraysInputBatch query.
ArraysInputScan(results pgx.BatchResults) (Arrays, error)
}
type DBQuerier struct {
conn genericConn // underlying Postgres transport to use
types *typeResolver // resolve types by name
}
var _ Querier = &DBQuerier{}
// genericConn is a connection to a Postgres database. This is usually backed by
// *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
type genericConn interface {
// Query executes sql with args. If there is an error the returned Rows will
// be returned in an error state. So it is allowed to ignore the error
// returned from Query and handle it in Rows.
Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
// QueryRow is a convenience wrapper over Query. Any error that occurs while
// querying is deferred until calling Scan on the returned Row. That Row will
// error with pgx.ErrNoRows if no rows are returned.
QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
// Exec executes sql. sql can be either a prepared statement name or an SQL
// string. arguments should be referenced positionally from the sql string
// as $1, $2, etc.
Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
}
// genericBatch batches queries to send in a single network request to a
// Postgres server. This is usually backed by *pgx.Batch.
type genericBatch interface {
// Queue queues a query to batch b. query can be an SQL query or the name of a
// prepared statement. See Queue on *pgx.Batch.
Queue(query string, arguments ...interface{})
}
// NewQuerier creates a DBQuerier that implements Querier. conn is typically
// *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func NewQuerier(conn genericConn) *DBQuerier {
return NewQuerierConfig(conn, QuerierConfig{})
}
type QuerierConfig struct {
// DataTypes contains pgtype.Value to use for encoding and decoding instead
// of pggen-generated pgtype.ValueTranscoder.
//
// If OIDs are available for an input parameter type and all of its
// transitive dependencies, pggen will use the binary encoding format for
// the input parameter.
DataTypes []pgtype.DataType
}
// NewQuerierConfig creates a DBQuerier that implements Querier with the given
// config. conn is typically *pgx.Conn, pgx.Tx, or *pgxpool.Pool.
func NewQuerierConfig(conn genericConn, cfg QuerierConfig) *DBQuerier {
return &DBQuerier{conn: conn, types: newTypeResolver(cfg.DataTypes)}
}
// WithTx creates a new DBQuerier that uses the transaction to run all queries.
func (q *DBQuerier) WithTx(tx pgx.Tx) (*DBQuerier, error) {
return &DBQuerier{conn: tx}, nil
}
// preparer is any Postgres connection transport that provides a way to prepare
// a statement, most commonly *pgx.Conn.
type preparer interface {
Prepare(ctx context.Context, name, sql string) (sd *pgconn.StatementDescription, err error)
}
// PrepareAllQueries executes a PREPARE statement for all pggen generated SQL
// queries in querier files. Typical usage is as the AfterConnect callback
// for pgxpool.Config
//
// pgx will use the prepared statement if available. Calling PrepareAllQueries
// is an optional optimization to avoid a network round-trip the first time pgx
// runs a query if pgx statement caching is enabled.
func PrepareAllQueries(ctx context.Context, p preparer) error {
if _, err := p.Prepare(ctx, searchScreenshotsSQL, searchScreenshotsSQL); err != nil {
return fmt.Errorf("prepare query 'SearchScreenshots': %w", err)
}
if _, err := p.Prepare(ctx, searchScreenshotsOneColSQL, searchScreenshotsOneColSQL); err != nil {
return fmt.Errorf("prepare query 'SearchScreenshotsOneCol': %w", err)
}
if _, err := p.Prepare(ctx, insertScreenshotBlocksSQL, insertScreenshotBlocksSQL); err != nil {
return fmt.Errorf("prepare query 'InsertScreenshotBlocks': %w", err)
}
if _, err := p.Prepare(ctx, arraysInputSQL, arraysInputSQL); err != nil {
return fmt.Errorf("prepare query 'ArraysInput': %w", err)
}
return nil
}
// Arrays represents the Postgres composite type "arrays".
type Arrays struct {
Texts []string `json:"texts"`
Int8s []*int `json:"int8s"`
Bools []bool `json:"bools"`
Floats []*float64 `json:"floats"`
}
// Blocks represents the Postgres composite type "blocks".
type Blocks struct {
ID int `json:"id"`
ScreenshotID int `json:"screenshot_id"`
Body string `json:"body"`
}
// typeResolver looks up the pgtype.ValueTranscoder by Postgres type name.
type typeResolver struct {
connInfo *pgtype.ConnInfo // types by Postgres type name
}
func newTypeResolver(types []pgtype.DataType) *typeResolver {
ci := pgtype.NewConnInfo()
for _, typ := range types {
if txt, ok := typ.Value.(textPreferrer); ok && typ.OID != unknownOID {
typ.Value = txt.ValueTranscoder
}
ci.RegisterDataType(typ)
}
return &typeResolver{connInfo: ci}
}
// findValue find the OID, and pgtype.ValueTranscoder for a Postgres type name.
func (tr *typeResolver) findValue(name string) (uint32, pgtype.ValueTranscoder, bool) {
typ, ok := tr.connInfo.DataTypeForName(name)
if !ok {
return 0, nil, false
}
v := pgtype.NewValue(typ.Value)
return typ.OID, v.(pgtype.ValueTranscoder), true
}
// setValue sets the value of a ValueTranscoder to a value that should always
// work and panics if it fails.
func (tr *typeResolver) setValue(vt pgtype.ValueTranscoder, val interface{}) pgtype.ValueTranscoder {
if err := vt.Set(val); err != nil {
panic(fmt.Sprintf("set ValueTranscoder %T to %+v: %s", vt, val, err))
}
return vt
}
type compositeField struct {
name string // name of the field
typeName string // Postgres type name
defaultVal pgtype.ValueTranscoder // default value to use
}
func (tr *typeResolver) newCompositeValue(name string, fields ...compositeField) pgtype.ValueTranscoder {
if _, val, ok := tr.findValue(name); ok {
return val
}
fs := make([]pgtype.CompositeTypeField, len(fields))
vals := make([]pgtype.ValueTranscoder, len(fields))
isBinaryOk := true
for i, field := range fields {
oid, val, ok := tr.findValue(field.typeName)
if !ok {
oid = unknownOID
val = field.defaultVal
}
isBinaryOk = isBinaryOk && oid != unknownOID
fs[i] = pgtype.CompositeTypeField{Name: field.name, OID: oid}
vals[i] = val
}
// Okay to ignore error because it's only thrown when the number of field
// names does not equal the number of ValueTranscoders.
typ, _ := pgtype.NewCompositeTypeValues(name, fs, vals)
if !isBinaryOk {
return textPreferrer{typ, name}
}
return typ
}
func (tr *typeResolver) newArrayValue(name, elemName string, defaultVal func() pgtype.ValueTranscoder) pgtype.ValueTranscoder {
if _, val, ok := tr.findValue(name); ok {
return val
}
elemOID, elemVal, ok := tr.findValue(elemName)
elemValFunc := func() pgtype.ValueTranscoder {
return pgtype.NewValue(elemVal).(pgtype.ValueTranscoder)
}
if !ok {
elemOID = unknownOID
elemValFunc = defaultVal
}
typ := pgtype.NewArrayType(name, elemOID, elemValFunc)
if elemOID == unknownOID {
return textPreferrer{typ, name}
}
return typ
}
// newArrays creates a new pgtype.ValueTranscoder for the Postgres
// composite type 'arrays'.
func (tr *typeResolver) newArrays() pgtype.ValueTranscoder {
return tr.newCompositeValue(
"arrays",
compositeField{"texts", "_text", &pgtype.TextArray{}},
compositeField{"int8s", "_int8", &pgtype.Int8Array{}},
compositeField{"bools", "_bool", &pgtype.BoolArray{}},
compositeField{"floats", "_float8", &pgtype.Float8Array{}},
)
}
// newArraysInit creates an initialized pgtype.ValueTranscoder for the
// Postgres composite type 'arrays' to encode query parameters.
func (tr *typeResolver) newArraysInit(v Arrays) pgtype.ValueTranscoder {
return tr.setValue(tr.newArrays(), tr.newArraysRaw(v))
}
// newArraysRaw returns all composite fields for the Postgres composite
// type 'arrays' as a slice of interface{} to encode query parameters.
func (tr *typeResolver) newArraysRaw(v Arrays) []interface{} {
return []interface{}{
v.Texts,
v.Int8s,
v.Bools,
v.Floats,
}
}
// newBlocks creates a new pgtype.ValueTranscoder for the Postgres
// composite type 'blocks'.
func (tr *typeResolver) newBlocks() pgtype.ValueTranscoder {
return tr.newCompositeValue(
"blocks",
compositeField{"id", "int4", &pgtype.Int4{}},
compositeField{"screenshot_id", "int8", &pgtype.Int8{}},
compositeField{"body", "text", &pgtype.Text{}},
)
}
// newBlocksArray creates a new pgtype.ValueTranscoder for the Postgres
// '_blocks' array type.
func (tr *typeResolver) newBlocksArray() pgtype.ValueTranscoder {
return tr.newArrayValue("_blocks", "blocks", tr.newBlocks)
}
// newboolArrayRaw returns all elements for the Postgres array type '_bool'
// as a slice of interface{} for use with the pgtype.Value Set method.
func (tr *typeResolver) newboolArrayRaw(vs []bool) []interface{} {
elems := make([]interface{}, len(vs))
for i, v := range vs {
elems[i] = v
}
return elems
}
const searchScreenshotsSQL = `SELECT
ss.id,
array_agg(bl) AS blocks
FROM screenshots ss
JOIN blocks bl ON bl.screenshot_id = ss.id
WHERE bl.body LIKE $1 || '%'
GROUP BY ss.id
ORDER BY ss.id
LIMIT $2 OFFSET $3;`
type SearchScreenshotsParams struct {
Body string
Limit int
Offset int
}
type SearchScreenshotsRow struct {
ID int `json:"id"`
Blocks []Blocks `json:"blocks"`
}
// SearchScreenshots implements Querier.SearchScreenshots.
func (q *DBQuerier) SearchScreenshots(ctx context.Context, params SearchScreenshotsParams) ([]SearchScreenshotsRow, error) {
ctx = context.WithValue(ctx, "pggen_query_name", "SearchScreenshots")
rows, err := q.conn.Query(ctx, searchScreenshotsSQL, params.Body, params.Limit, params.Offset)
if err != nil {
return nil, fmt.Errorf("query SearchScreenshots: %w", err)
}
defer rows.Close()
items := []SearchScreenshotsRow{}
blocksArray := q.types.newBlocksArray()
for rows.Next() {
var item SearchScreenshotsRow
if err := rows.Scan(&item.ID, blocksArray); err != nil {
return nil, fmt.Errorf("scan SearchScreenshots row: %w", err)
}
if err := blocksArray.AssignTo(&item.Blocks); err != nil {
return nil, fmt.Errorf("assign SearchScreenshots row: %w", err)
}
items = append(items, item)
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("close SearchScreenshots rows: %w", err)
}
return items, err
}
// SearchScreenshotsBatch implements Querier.SearchScreenshotsBatch.
func (q *DBQuerier) SearchScreenshotsBatch(batch genericBatch, params SearchScreenshotsParams) {
batch.Queue(searchScreenshotsSQL, params.Body, params.Limit, params.Offset)
}
// SearchScreenshotsScan implements Querier.SearchScreenshotsScan.
func (q *DBQuerier) SearchScreenshotsScan(results pgx.BatchResults) ([]SearchScreenshotsRow, error) {
rows, err := results.Query()
if err != nil {
return nil, fmt.Errorf("query SearchScreenshotsBatch: %w", err)
}
defer rows.Close()
items := []SearchScreenshotsRow{}
blocksArray := q.types.newBlocksArray()
for rows.Next() {
var item SearchScreenshotsRow
if err := rows.Scan(&item.ID, blocksArray); err != nil {
return nil, fmt.Errorf("scan SearchScreenshotsBatch row: %w", err)
}
if err := blocksArray.AssignTo(&item.Blocks); err != nil {
return nil, fmt.Errorf("assign SearchScreenshots row: %w", err)
}
items = append(items, item)
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("close SearchScreenshotsBatch rows: %w", err)
}
return items, err
}
const searchScreenshotsOneColSQL = `SELECT
array_agg(bl) AS blocks
FROM screenshots ss
JOIN blocks bl ON bl.screenshot_id = ss.id
WHERE bl.body LIKE $1 || '%'
GROUP BY ss.id
ORDER BY ss.id
LIMIT $2 OFFSET $3;`
type SearchScreenshotsOneColParams struct {
Body string
Limit int
Offset int
}
// SearchScreenshotsOneCol implements Querier.SearchScreenshotsOneCol.
func (q *DBQuerier) SearchScreenshotsOneCol(ctx context.Context, params SearchScreenshotsOneColParams) ([][]Blocks, error) {
ctx = context.WithValue(ctx, "pggen_query_name", "SearchScreenshotsOneCol")
rows, err := q.conn.Query(ctx, searchScreenshotsOneColSQL, params.Body, params.Limit, params.Offset)
if err != nil {
return nil, fmt.Errorf("query SearchScreenshotsOneCol: %w", err)
}
defer rows.Close()
items := [][]Blocks{}
blocksArray := q.types.newBlocksArray()
for rows.Next() {
var item []Blocks
if err := rows.Scan(blocksArray); err != nil {
return nil, fmt.Errorf("scan SearchScreenshotsOneCol row: %w", err)
}
if err := blocksArray.AssignTo(&item); err != nil {
return nil, fmt.Errorf("assign SearchScreenshotsOneCol row: %w", err)
}
items = append(items, item)
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("close SearchScreenshotsOneCol rows: %w", err)
}
return items, err
}
// SearchScreenshotsOneColBatch implements Querier.SearchScreenshotsOneColBatch.
func (q *DBQuerier) SearchScreenshotsOneColBatch(batch genericBatch, params SearchScreenshotsOneColParams) {
batch.Queue(searchScreenshotsOneColSQL, params.Body, params.Limit, params.Offset)
}
// SearchScreenshotsOneColScan implements Querier.SearchScreenshotsOneColScan.
func (q *DBQuerier) SearchScreenshotsOneColScan(results pgx.BatchResults) ([][]Blocks, error) {
rows, err := results.Query()
if err != nil {
return nil, fmt.Errorf("query SearchScreenshotsOneColBatch: %w", err)
}
defer rows.Close()
items := [][]Blocks{}
blocksArray := q.types.newBlocksArray()
for rows.Next() {
var item []Blocks
if err := rows.Scan(blocksArray); err != nil {
return nil, fmt.Errorf("scan SearchScreenshotsOneColBatch row: %w", err)
}
if err := blocksArray.AssignTo(&item); err != nil {
return nil, fmt.Errorf("assign SearchScreenshotsOneCol row: %w", err)
}
items = append(items, item)
}
if err := rows.Err(); err != nil {
return nil, fmt.Errorf("close SearchScreenshotsOneColBatch rows: %w", err)
}
return items, err
}
const insertScreenshotBlocksSQL = `WITH screens AS (
INSERT INTO screenshots (id) VALUES ($1)
ON CONFLICT DO NOTHING
)
INSERT
INTO blocks (screenshot_id, body)
VALUES ($1, $2)
RETURNING id, screenshot_id, body;`
type InsertScreenshotBlocksRow struct {
ID int `json:"id"`
ScreenshotID int `json:"screenshot_id"`
Body string `json:"body"`
}
// InsertScreenshotBlocks implements Querier.InsertScreenshotBlocks.
func (q *DBQuerier) InsertScreenshotBlocks(ctx context.Context, screenshotID int, body string) (InsertScreenshotBlocksRow, error) {
ctx = context.WithValue(ctx, "pggen_query_name", "InsertScreenshotBlocks")
row := q.conn.QueryRow(ctx, insertScreenshotBlocksSQL, screenshotID, body)
var item InsertScreenshotBlocksRow
if err := row.Scan(&item.ID, &item.ScreenshotID, &item.Body); err != nil {
return item, fmt.Errorf("query InsertScreenshotBlocks: %w", err)
}
return item, nil
}
// InsertScreenshotBlocksBatch implements Querier.InsertScreenshotBlocksBatch.
func (q *DBQuerier) InsertScreenshotBlocksBatch(batch genericBatch, screenshotID int, body string) {
batch.Queue(insertScreenshotBlocksSQL, screenshotID, body)
}
// InsertScreenshotBlocksScan implements Querier.InsertScreenshotBlocksScan.
func (q *DBQuerier) InsertScreenshotBlocksScan(results pgx.BatchResults) (InsertScreenshotBlocksRow, error) {
row := results.QueryRow()
var item InsertScreenshotBlocksRow
if err := row.Scan(&item.ID, &item.ScreenshotID, &item.Body); err != nil {
return item, fmt.Errorf("scan InsertScreenshotBlocksBatch row: %w", err)
}
return item, nil
}
const arraysInputSQL = `SELECT $1::arrays;`
// ArraysInput implements Querier.ArraysInput.
func (q *DBQuerier) ArraysInput(ctx context.Context, arrays Arrays) (Arrays, error) {
ctx = context.WithValue(ctx, "pggen_query_name", "ArraysInput")
row := q.conn.QueryRow(ctx, arraysInputSQL, q.types.newArraysInit(arrays))
var item Arrays
arraysRow := q.types.newArrays()
if err := row.Scan(arraysRow); err != nil {
return item, fmt.Errorf("query ArraysInput: %w", err)
}
if err := arraysRow.AssignTo(&item); err != nil {
return item, fmt.Errorf("assign ArraysInput row: %w", err)
}
return item, nil
}
// ArraysInputBatch implements Querier.ArraysInputBatch.
func (q *DBQuerier) ArraysInputBatch(batch genericBatch, arrays Arrays) {
batch.Queue(arraysInputSQL, q.types.newArraysInit(arrays))
}
// ArraysInputScan implements Querier.ArraysInputScan.
func (q *DBQuerier) ArraysInputScan(results pgx.BatchResults) (Arrays, error) {
row := results.QueryRow()
var item Arrays
arraysRow := q.types.newArrays()
if err := row.Scan(arraysRow); err != nil {
return item, fmt.Errorf("scan ArraysInputBatch row: %w", err)
}
if err := arraysRow.AssignTo(&item); err != nil {
return item, fmt.Errorf("assign ArraysInput row: %w", err)
}
return item, nil
}
// textPreferrer wraps a pgtype.ValueTranscoder and sets the preferred encoding
// format to text instead binary (the default). pggen uses the text format
// when the OID is unknownOID because the binary format requires the OID.
// Typically occurs if the results from QueryAllDataTypes aren't passed to
// NewQuerierConfig.
type textPreferrer struct {
pgtype.ValueTranscoder
typeName string
}
// PreferredParamFormat implements pgtype.ParamFormatPreferrer.
func (t textPreferrer) PreferredParamFormat() int16 { return pgtype.TextFormatCode }
func (t textPreferrer) NewTypeValue() pgtype.Value {
return textPreferrer{pgtype.NewValue(t.ValueTranscoder).(pgtype.ValueTranscoder), t.typeName}
}
func (t textPreferrer) TypeName() string {
return t.typeName
}
// unknownOID means we don't know the OID for a type. This is okay for decoding
// because pgx call DecodeText or DecodeBinary without requiring the OID. For
// encoding parameters, pggen uses textPreferrer if the OID is unknown.
const unknownOID = 0