MCPcopy Create free account
hub / github.com/bytebase/bytebase / convertAnyToRowValue

Function convertAnyToRowValue

frontend/src/utils/sqlResult.ts:118–252  ·  view source on GitHub ↗
(
  value: unknown,
  nested: boolean
)

Source from the content-addressed store, hash-verified

116};
117
118const convertAnyToRowValue = (
119 value: unknown,
120 nested: boolean
121): { value: RowValue; type: string } => {
122 switch (typeof value) {
123 case "number": {
124 if (Math.floor(value) === value) {
125 return {
126 value: createProto(RowValueSchema, {
127 kind: {
128 case: "int32Value",
129 value: value,
130 },
131 }),
132 type: "INTEGER",
133 };
134 }
135 return {
136 value: createProto(RowValueSchema, {
137 kind: {
138 case: "floatValue",
139 value: value,
140 },
141 }),
142 type: "FLOAT",
143 };
144 }
145 case "string":
146 return {
147 value: createProto(RowValueSchema, {
148 kind: {
149 case: "stringValue",
150 value: value,
151 },
152 }),
153 type: "TEXT",
154 };
155 case "undefined":
156 return {
157 value: createProto(RowValueSchema, {
158 kind: {
159 case: "nullValue",
160 value: NullValue.NULL_VALUE,
161 },
162 }),
163 type: "NULL",
164 };
165 case "boolean":
166 return {
167 value: createProto(RowValueSchema, {
168 kind: {
169 case: "boolValue",
170 value: value,
171 },
172 }),
173 type: "BOOLEAN",
174 };
175 case "bigint":

Callers 2

flattenNoSQLQueryResultFunction · 0.85
buildESHitRowFunction · 0.85

Calls 2

flattenNoSQLColumnFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected