Skip to content

Commit 2ed1367

Browse files
committed
Adjust Type generation to match old behavior
1 parent 844a039 commit 2ed1367

File tree

2 files changed

+73
-27
lines changed

2 files changed

+73
-27
lines changed

codegen/src/types.rs

+10
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
7070
let name = split[5];
7171

7272
let variant = match name {
73+
"anyarray" => "AnyArray".to_owned(),
74+
// FIXME remove following overrides for 0.12
7375
"anyrange" => "Anyrange".to_owned(),
76+
"tsvector" => "Tsvector".to_owned(),
77+
"gtsvector" => "Gtsvector".to_owned(),
78+
"_tsvector" => "TsvectorArray".to_owned(),
79+
"_gtsvector" => "GtsvectorArray".to_owned(),
7480
"timestamptz" => "TimestampTZ".to_owned(),
7581
"_timestamptz" => "TimestampTZArray".to_owned(),
7682
name => {
@@ -81,10 +87,14 @@ fn parse_types(ranges: &BTreeMap<u32, u32>) -> BTreeMap<u32, Type> {
8187
};
8288

8389
let kind = split[11];
90+
91+
// FIXME enable for 0.12
92+
/*
8493
// we need to be able to pull composite fields and enum variants at runtime
8594
if kind == "C" || kind == "E" {
8695
continue;
8796
}
97+
*/
8898

8999
let element = if let Some(&element) = ranges.get(&oid) {
90100
element

src/types/types.rs

+63-27
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ pub enum Type {
3838
OidVector,
3939
/// PG_DDL_COMMAND - internal type for passing CollectedCommand
4040
PgDdlCommand,
41+
/// PG_TYPE
42+
PgType,
43+
/// PG_ATTRIBUTE
44+
PgAttribute,
45+
/// PG_PROC
46+
PgProc,
47+
/// PG_CLASS
48+
PgClass,
4149
/// JSON
4250
Json,
4351
/// XML - XML content
@@ -227,7 +235,7 @@ pub enum Type {
227235
/// ANY
228236
Any,
229237
/// ANYARRAY
230-
Anyarray,
238+
AnyArray,
231239
/// VOID
232240
Void,
233241
/// TRIGGER
@@ -263,15 +271,15 @@ pub enum Type {
263271
/// ANYENUM
264272
Anyenum,
265273
/// TSVECTOR - text representation for text search
266-
TsVector,
274+
Tsvector,
267275
/// TSQUERY - query representation for text search
268276
Tsquery,
269277
/// GTSVECTOR - GiST index internal text representation for text search
270-
GtsVector,
278+
Gtsvector,
271279
/// TSVECTOR&#91;&#93;
272-
TsVectorArray,
280+
TsvectorArray,
273281
/// GTSVECTOR&#91;&#93;
274-
GtsVectorArray,
282+
GtsvectorArray,
275283
/// TSQUERY&#91;&#93;
276284
TsqueryArray,
277285
/// REGCONFIG - registered text search configuration
@@ -357,6 +365,10 @@ impl Type {
357365
29 => Some(Type::Cid),
358366
30 => Some(Type::OidVector),
359367
32 => Some(Type::PgDdlCommand),
368+
71 => Some(Type::PgType),
369+
75 => Some(Type::PgAttribute),
370+
81 => Some(Type::PgProc),
371+
83 => Some(Type::PgClass),
360372
114 => Some(Type::Json),
361373
142 => Some(Type::Xml),
362374
143 => Some(Type::XmlArray),
@@ -451,7 +463,7 @@ impl Type {
451463
2249 => Some(Type::Record),
452464
2275 => Some(Type::Cstring),
453465
2276 => Some(Type::Any),
454-
2277 => Some(Type::Anyarray),
466+
2277 => Some(Type::AnyArray),
455467
2278 => Some(Type::Void),
456468
2279 => Some(Type::Trigger),
457469
2280 => Some(Type::LanguageHandler),
@@ -469,11 +481,11 @@ impl Type {
469481
3221 => Some(Type::PgLsnArray),
470482
3310 => Some(Type::TsmHandler),
471483
3500 => Some(Type::Anyenum),
472-
3614 => Some(Type::TsVector),
484+
3614 => Some(Type::Tsvector),
473485
3615 => Some(Type::Tsquery),
474-
3642 => Some(Type::GtsVector),
475-
3643 => Some(Type::TsVectorArray),
476-
3644 => Some(Type::GtsVectorArray),
486+
3642 => Some(Type::Gtsvector),
487+
3643 => Some(Type::TsvectorArray),
488+
3644 => Some(Type::GtsvectorArray),
477489
3645 => Some(Type::TsqueryArray),
478490
3734 => Some(Type::Regconfig),
479491
3735 => Some(Type::RegconfigArray),
@@ -522,6 +534,10 @@ impl Type {
522534
Type::Cid => 29,
523535
Type::OidVector => 30,
524536
Type::PgDdlCommand => 32,
537+
Type::PgType => 71,
538+
Type::PgAttribute => 75,
539+
Type::PgProc => 81,
540+
Type::PgClass => 83,
525541
Type::Json => 114,
526542
Type::Xml => 142,
527543
Type::XmlArray => 143,
@@ -616,7 +632,7 @@ impl Type {
616632
Type::Record => 2249,
617633
Type::Cstring => 2275,
618634
Type::Any => 2276,
619-
Type::Anyarray => 2277,
635+
Type::AnyArray => 2277,
620636
Type::Void => 2278,
621637
Type::Trigger => 2279,
622638
Type::LanguageHandler => 2280,
@@ -634,11 +650,11 @@ impl Type {
634650
Type::PgLsnArray => 3221,
635651
Type::TsmHandler => 3310,
636652
Type::Anyenum => 3500,
637-
Type::TsVector => 3614,
653+
Type::Tsvector => 3614,
638654
Type::Tsquery => 3615,
639-
Type::GtsVector => 3642,
640-
Type::TsVectorArray => 3643,
641-
Type::GtsVectorArray => 3644,
655+
Type::Gtsvector => 3642,
656+
Type::TsvectorArray => 3643,
657+
Type::GtsvectorArray => 3644,
642658
Type::TsqueryArray => 3645,
643659
Type::Regconfig => 3734,
644660
Type::RegconfigArray => 3735,
@@ -735,6 +751,22 @@ impl Type {
735751
const V: &'static Kind = &Kind::Pseudo;
736752
V
737753
}
754+
Type::PgType => {
755+
const V: &'static Kind = &Kind::Simple;
756+
V
757+
}
758+
Type::PgAttribute => {
759+
const V: &'static Kind = &Kind::Simple;
760+
V
761+
}
762+
Type::PgProc => {
763+
const V: &'static Kind = &Kind::Simple;
764+
V
765+
}
766+
Type::PgClass => {
767+
const V: &'static Kind = &Kind::Simple;
768+
V
769+
}
738770
Type::Json => {
739771
const V: &'static Kind = &Kind::Simple;
740772
V
@@ -1111,7 +1143,7 @@ impl Type {
11111143
const V: &'static Kind = &Kind::Pseudo;
11121144
V
11131145
}
1114-
Type::Anyarray => {
1146+
Type::AnyArray => {
11151147
const V: &'static Kind = &Kind::Pseudo;
11161148
V
11171149
}
@@ -1183,24 +1215,24 @@ impl Type {
11831215
const V: &'static Kind = &Kind::Pseudo;
11841216
V
11851217
}
1186-
Type::TsVector => {
1218+
Type::Tsvector => {
11871219
const V: &'static Kind = &Kind::Simple;
11881220
V
11891221
}
11901222
Type::Tsquery => {
11911223
const V: &'static Kind = &Kind::Simple;
11921224
V
11931225
}
1194-
Type::GtsVector => {
1226+
Type::Gtsvector => {
11951227
const V: &'static Kind = &Kind::Simple;
11961228
V
11971229
}
1198-
Type::TsVectorArray => {
1199-
const V: &'static Kind = &Kind::Array(Type::TsVector);
1230+
Type::TsvectorArray => {
1231+
const V: &'static Kind = &Kind::Array(Type::Tsvector);
12001232
V
12011233
}
1202-
Type::GtsVectorArray => {
1203-
const V: &'static Kind = &Kind::Array(Type::GtsVector);
1234+
Type::GtsvectorArray => {
1235+
const V: &'static Kind = &Kind::Array(Type::Gtsvector);
12041236
V
12051237
}
12061238
Type::TsqueryArray => {
@@ -1334,6 +1366,10 @@ impl Type {
13341366
Type::Cid => "cid",
13351367
Type::OidVector => "oidvector",
13361368
Type::PgDdlCommand => "pg_ddl_command",
1369+
Type::PgType => "pg_type",
1370+
Type::PgAttribute => "pg_attribute",
1371+
Type::PgProc => "pg_proc",
1372+
Type::PgClass => "pg_class",
13371373
Type::Json => "json",
13381374
Type::Xml => "xml",
13391375
Type::XmlArray => "_xml",
@@ -1428,7 +1464,7 @@ impl Type {
14281464
Type::Record => "record",
14291465
Type::Cstring => "cstring",
14301466
Type::Any => "any",
1431-
Type::Anyarray => "anyarray",
1467+
Type::AnyArray => "anyarray",
14321468
Type::Void => "void",
14331469
Type::Trigger => "trigger",
14341470
Type::LanguageHandler => "language_handler",
@@ -1446,11 +1482,11 @@ impl Type {
14461482
Type::PgLsnArray => "_pg_lsn",
14471483
Type::TsmHandler => "tsm_handler",
14481484
Type::Anyenum => "anyenum",
1449-
Type::TsVector => "tsvector",
1485+
Type::Tsvector => "tsvector",
14501486
Type::Tsquery => "tsquery",
1451-
Type::GtsVector => "gtsvector",
1452-
Type::TsVectorArray => "_tsvector",
1453-
Type::GtsVectorArray => "_gtsvector",
1487+
Type::Gtsvector => "gtsvector",
1488+
Type::TsvectorArray => "_tsvector",
1489+
Type::GtsvectorArray => "_gtsvector",
14541490
Type::TsqueryArray => "_tsquery",
14551491
Type::Regconfig => "regconfig",
14561492
Type::RegconfigArray => "_regconfig",

0 commit comments

Comments
 (0)