MCPcopy Create free account
hub / github.com/observablehq/framework / sqliteType

Function sqliteType

src/client/stdlib/sqlite.js:86–121  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

84
85// https://www.sqlite.org/datatype3.html
86function sqliteType(type) {
87 switch (type) {
88 case "NULL":
89 return "null";
90 case "INT":
91 case "INTEGER":
92 case "TINYINT":
93 case "SMALLINT":
94 case "MEDIUMINT":
95 case "BIGINT":
96 case "UNSIGNED BIG INT":
97 case "INT2":
98 case "INT8":
99 return "integer";
100 case "TEXT":
101 case "CLOB":
102 return "string";
103 case "REAL":
104 case "DOUBLE":
105 case "DOUBLE PRECISION":
106 case "FLOAT":
107 case "NUMERIC":
108 return "number";
109 case "BLOB":
110 return "buffer";
111 case "DATE":
112 case "DATETIME":
113 return "string"; // TODO convert strings to Date instances in sql.js
114 default:
115 return /^(?:(?:(?:VARYING|NATIVE) )?CHARACTER|(?:N|VAR|NVAR)CHAR)\(/.test(type)
116 ? "string"
117 : /^(?:DECIMAL|NUMERIC)\(/.test(type)
118 ? "number"
119 : "other";
120 }
121}
122
123function load(source) {
124 return typeof source === "string"

Callers 1

describeColumnsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected