1 | <?php |
||
34 | class StdCoreFactory implements ICoreFactory |
||
35 | { |
||
36 | public function createGlobalTypeRegister(): TypeRegister |
||
37 | { |
||
38 | $reg = new TypeRegister(); |
||
39 | $reg->registerTypeLoader(new StdTypeLoader()); |
||
40 | $reg->registerRangeCanonicalFuncProvider(new StdRangeCanonicalFuncProvider()); |
||
41 | |||
42 | $reservedTypes = Lang\Sql\Types::getReservedTypes(); |
||
43 | foreach ($reservedTypes as $alias => list($implSchema, $implName)) { |
||
44 | $reg->registerTypeAbbreviation($alias, $implSchema, $implName); |
||
45 | } |
||
46 | |||
47 | // standard value serializers |
||
48 | $reg->registerValueSerializer('sql', new SqlSerializer()); |
||
49 | $reg->registerValueSerializer('ident', new IdentifierSerializer()); |
||
50 | $reg->registerValueSerializer('qident', new QuotedIdentifierSerializer()); |
||
51 | $reg->registerValueSerializer('rel', new RelationSerializer()); |
||
52 | $reg->registerValueSerializer('cmd', new CommandSerializer()); |
||
53 | |||
54 | // standard type abbreviations |
||
55 | $reg->registerTypeAbbreviation('s', 'pg_catalog', 'text'); |
||
56 | $reg->registerTypeAbbreviation('i', 'pg_catalog', 'bigint'); |
||
57 | $reg->registerTypeAbbreviation('num', 'pg_catalog', 'numeric'); |
||
58 | $reg->registerTypeAbbreviation('f', 'pg_catalog', 'float8'); |
||
59 | $reg->registerTypeAbbreviation('ts', 'pg_catalog', 'timestamp'); |
||
60 | $reg->registerTypeAbbreviation('tstz', 'pg_catalog', 'timestamptz'); |
||
61 | |||
62 | // standard type recognition rules |
||
63 | $reg->addTypeRecognitionRule('int', 'pg_catalog', 'int8'); |
||
64 | $reg->addTypeRecognitionRule('string', 'pg_catalog', 'text'); |
||
65 | $reg->addTypeRecognitionRule('bool', 'pg_catalog', 'bool'); |
||
66 | $reg->addTypeRecognitionRule('float', 'pg_catalog', 'float8'); |
||
67 | $reg->addTypeRecognitionRule('null', 'pg_catalog', 'text'); |
||
68 | $reg->addTypeRecognitionRule('array', 'pg_catalog', 'text[]'); |
||
69 | $reg->addTypeRecognitionRule(\Ivory\Value\Decimal::class, 'pg_catalog', 'numeric'); |
||
70 | $reg->addTypeRecognitionRule(\Ivory\Value\Date::class, 'pg_catalog', 'date'); |
||
71 | $reg->addTypeRecognitionRule(\Ivory\Value\Time::class, 'pg_catalog', 'time'); |
||
72 | $reg->addTypeRecognitionRule(\Ivory\Value\TimeTz::class, 'pg_catalog', 'timetz'); |
||
73 | $reg->addTypeRecognitionRule(\Ivory\Value\Timestamp::class, 'pg_catalog', 'timestamp'); |
||
74 | $reg->addTypeRecognitionRule(\Ivory\Value\TimestampTz::class, 'pg_catalog', 'timestamptz'); |
||
75 | $reg->addTypeRecognitionRule(\Ivory\Value\TimeInterval::class, 'pg_catalog', 'interval'); |
||
76 | $reg->addTypeRecognitionRule(\Ivory\Value\FixedBitString::class, 'pg_catalog', 'bit'); |
||
77 | $reg->addTypeRecognitionRule(\Ivory\Value\VarBitString::class, 'pg_catalog', 'varbit'); |
||
78 | $reg->addTypeRecognitionRule(\Ivory\Value\Json::class, 'pg_catalog', 'json'); |
||
79 | $reg->addTypeRecognitionRule(\Ivory\Value\XmlContent::class, 'pg_catalog', 'xml'); |
||
80 | $reg->addTypeRecognitionRule(\Ivory\Value\XmlDocument::class, 'pg_catalog', 'xml'); |
||
81 | $reg->addTypeRecognitionRule(\DOMDocument::class, 'pg_catalog', 'xml'); |
||
82 | $reg->addTypeRecognitionRule(\DOMNode::class, 'pg_catalog', 'xml'); |
||
83 | $reg->addTypeRecognitionRule(\DOMNodeList::class, 'pg_catalog', 'xml'); |
||
84 | $reg->addTypeRecognitionRule(\SimpleXMLElement::class, 'pg_catalog', 'xml'); |
||
85 | $reg->addTypeRecognitionRule(\Ivory\Value\Point::class, 'pg_catalog', 'point'); |
||
86 | $reg->addTypeRecognitionRule(\Ivory\Value\Line::class, 'pg_catalog', 'line'); |
||
87 | $reg->addTypeRecognitionRule(\Ivory\Value\LineSegment::class, 'pg_catalog', 'lseg'); |
||
88 | $reg->addTypeRecognitionRule(\Ivory\Value\Box::class, 'pg_catalog', 'box'); |
||
89 | $reg->addTypeRecognitionRule(\Ivory\Value\Path::class, 'pg_catalog', 'path'); |
||
90 | $reg->addTypeRecognitionRule(\Ivory\Value\Polygon::class, 'pg_catalog', 'polygon'); |
||
91 | $reg->addTypeRecognitionRule(\Ivory\Value\Circle::class, 'pg_catalog', 'circle'); |
||
92 | $reg->addTypeRecognitionRule(\Ivory\Value\NetAddress::class, 'pg_catalog', 'inet'); |
||
93 | $reg->addTypeRecognitionRule(\Ivory\Value\MacAddr::class, 'pg_catalog', 'macaddr'); |
||
94 | $reg->addTypeRecognitionRule(\Ivory\Value\Money::class, 'pg_catalog', 'money'); |
||
95 | $reg->addTypeRecognitionRule(\Ivory\Value\PgLogSequenceNumber::class, 'pg_catalog', 'pg_lsn'); |
||
96 | $reg->addTypeRecognitionRule(\Ivory\Value\TxIdSnapshot::class, 'pg_catalog', 'txid_snapshot'); |
||
97 | $reg->addTypeRecognitionRule(\Ivory\Value\TextSearchVector::class, 'pg_catalog', 'tsvector'); |
||
98 | $reg->addTypeRecognitionRule(\Ivory\Value\TextSearchQuery::class, 'pg_catalog', 'tsquery'); |
||
99 | |||
100 | return $reg; |
||
101 | } |
||
102 | |||
103 | public function createSqlPatternParser(ICacheControl $cacheControl = null): ISqlPatternParser |
||
104 | { |
||
105 | if ($cacheControl === null) { |
||
106 | return new SqlPatternParser(); |
||
107 | } else { |
||
108 | return new CachingSqlPatternParser($cacheControl); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | public function createStatementExceptionFactory(): StatementExceptionFactory |
||
113 | { |
||
114 | return new StatementExceptionFactory(); |
||
115 | } |
||
116 | |||
117 | public function createConnection(string $connName, ConnectionParameters $params): IConnection |
||
118 | { |
||
119 | return new Connection($connName, $params); |
||
120 | } |
||
121 | |||
122 | public function createCacheControl(IConnection $connection = null): ICacheControl |
||
140 | |||
141 | public function createTransactionHandle( |
||
142 | IStatementExecution $stmtExec, |
||
143 | IObservableTransactionControl $observableTxCtl |
||
144 | ): ITxHandle { |
||
147 | } |
||
148 |