18 using System.Collections.Generic;
24 namespace Deveel.Data.Sql.Parser {
34 Metadata =
new Dictionary<string, string>();
42 public bool IsPrimitive {
get;
private set; }
47 public string TypeName {
get;
private set; }
56 public int Size {
get;
private set; }
63 public bool HasSize {
get;
private set; }
74 public int Scale {
get;
private set; }
81 public bool HasScale {
get;
private set; }
88 public int Precision {
get;
private set; }
94 public bool HasPrecision {
get;
private set; }
102 public string Locale {
get;
private set; }
109 public bool HasLocale {
get;
private set; }
111 public string Encoding {
get;
private set; }
113 public bool HasEncoding {
get;
private set; }
115 public Dictionary<string, string> Metadata {
get;
private set; }
118 if (node.
NodeName ==
"identity_type") {
119 TypeName =
"IDENTITY";
120 }
else if (node.
NodeName ==
"boolean_type") {
121 GetBooleanType(node);
122 }
else if (node.
NodeName ==
"decimal_type") {
124 }
else if (node.
NodeName ==
"character_type" ||
127 }
else if (node.
NodeName ==
"date_type" ||
131 }
else if (node.
NodeName ==
"interval_type") {
132 }
else if (node.
NodeName ==
"user_type") {
134 }
else if (node.
NodeName ==
"row_type") {
138 return base.OnChildNode(node);
143 TypeName =
"BOOLEAN";
149 var optMetaList = node.FindByName(
"user_type_meta_opt");
150 if (optMetaList != null) {
151 GetMeta(optMetaList.ChildNodes.FirstOrDefault());
160 foreach (var meta
in metas) {
161 Metadata[meta.Name] = meta.
Value;
167 TypeName = type.NodeName;
171 foreach (var childNode
in node.ChildNodes) {
172 if (childNode.NodeName ==
"long_varchar") {
173 TypeName =
"LONG VARCHAR";
175 TypeName = ((SqlKeyNode) childNode).Text;
176 }
else if (childNode.NodeName ==
"datatype_size") {
177 GetDataSize(childNode);
178 }
else if (childNode.NodeName ==
"locale_opt") {
179 GetLocale(childNode);
180 }
else if (childNode.NodeName ==
"encoding_opt") {
181 GetEncoding(childNode);
187 foreach (var childNode
in node.ChildNodes) {
189 Locale = ((StringLiteralNode) childNode).Value;
196 foreach (var childNode
in node.ChildNodes) {
198 Encoding = ((StringLiteralNode) childNode).Value;
205 foreach (var childNode
in node.ChildNodes) {
207 Size = (int) ((IntegerLiteralNode) childNode).Value;
214 foreach (var childNode
in node.ChildNodes) {
216 TypeName = ((SqlKeyNode) childNode).Text;
217 }
else if (childNode.NodeName ==
"number_precision") {
218 GetNumberPrecision(childNode);
225 foreach (var childNode
in node.ChildNodes) {
void GetMeta(ISqlNode node)
override ISqlNode OnChildNode(ISqlNode node)
During the initialization of the node from the parser, this method is called for every child node add...
Defines the contract for nodes in an AST model for a SQL grammar analysis and parsing.
Represents a keyword found during the compilation of a source text.
void GetBooleanType(ISqlNode node)
Represents a composed name for an object within the system.
string NodeName
Gets the name of the node analyzed from the parser.
void GetNumberType(ISqlNode node)
void GetUserType(ISqlNode node)
void GetSizedType(ISqlNode node)
A node containing a constant literal string passed within an SQL command.
IEnumerable< ISqlNode > ChildNodes
Gets a read-only enumeration of the children nodes, if any.
void GetSimpleType(ISqlNode node)
void GetDataSize(ISqlNode node)
DataTypeNode()
Constructs an empty DataTypeNode.
void GetNumberPrecision(ISqlNode node)
Describes the information of a data type as found in a SQL string.
The default implementation of ISqlNode, that is a node in the text analysis parsing of SQL commands...
Encapsulates a number that is any falling in the group of integers.
void GetLocale(ISqlNode node)
void GetEncoding(ISqlNode node)