mirror of https://github.com/Fabio286/antares.git
fix: unable to copy as sql inserts with BIT fileds, fixes #613
This commit is contained in:
parent
38bfea279c
commit
6e01f0f2e7
|
@ -72,7 +72,7 @@ export const escapeAndQuote = (val: string, client: ClientCode) => {
|
||||||
export const valueToSqlString = (args: {
|
export const valueToSqlString = (args: {
|
||||||
val: any;
|
val: any;
|
||||||
client: ClientCode;
|
client: ClientCode;
|
||||||
field: {type: string; datePrecision: number; isArray?: boolean};
|
field: {type: string; datePrecision?: number; precision?: number | false; isArray?: boolean};
|
||||||
}): string => {
|
}): string => {
|
||||||
let parsedValue;
|
let parsedValue;
|
||||||
const { val, client, field } = args;
|
const { val, client, field } = args;
|
||||||
|
@ -105,7 +105,7 @@ export const valueToSqlString = (args: {
|
||||||
else if (TEXT_SEARCH.includes(field.type))
|
else if (TEXT_SEARCH.includes(field.type))
|
||||||
parsedValue = `'${val.replaceAll('\'', '\'\'')}'`;
|
parsedValue = `'${val.replaceAll('\'', '\'\'')}'`;
|
||||||
else if (BIT.includes(field.type))
|
else if (BIT.includes(field.type))
|
||||||
parsedValue = `b'${hexToBinary(Buffer.from(val).toString('hex') as undefined as HexChar[])}'`;
|
parsedValue = `b'${hexToBinary(Buffer.from(new Uint8Array(Object.values(val))).toString('hex') as undefined as HexChar[])}'`;
|
||||||
else if (BLOB.includes(field.type)) {
|
else if (BLOB.includes(field.type)) {
|
||||||
let buffer: Buffer;
|
let buffer: Buffer;
|
||||||
if (val instanceof Uint8Array)
|
if (val instanceof Uint8Array)
|
||||||
|
|
|
@ -293,7 +293,7 @@ const inputProps = computed(() => {
|
||||||
let timeMask = '##:##:##';
|
let timeMask = '##:##:##';
|
||||||
const precision = props.fields[editingField.value].length;
|
const precision = props.fields[editingField.value].length;
|
||||||
|
|
||||||
for (let i = 0; i < precision; i++)
|
for (let i = 0; i < Number(precision); i++)
|
||||||
timeMask += i === 0 ? '.#' : '#';
|
timeMask += i === 0 ? '.#' : '#';
|
||||||
|
|
||||||
if (HAS_TIMEZONE.includes(editingType.value))
|
if (HAS_TIMEZONE.includes(editingType.value))
|
||||||
|
@ -309,7 +309,7 @@ const inputProps = computed(() => {
|
||||||
let datetimeMask = '####-##-## ##:##:##';
|
let datetimeMask = '####-##-## ##:##:##';
|
||||||
const precision = props.fields[editingField.value].length;
|
const precision = props.fields[editingField.value].length;
|
||||||
|
|
||||||
for (let i = 0; i < precision; i++)
|
for (let i = 0; i < Number(precision); i++)
|
||||||
datetimeMask += i === 0 ? '.#' : '#';
|
datetimeMask += i === 0 ? '.#' : '#';
|
||||||
|
|
||||||
if (HAS_TIMEZONE.includes(editingType.value))
|
if (HAS_TIMEZONE.includes(editingType.value))
|
||||||
|
@ -582,7 +582,7 @@ const typeFormat = (val: string | number | Date | number[], type: string, precis
|
||||||
return val;
|
return val;
|
||||||
|
|
||||||
let datePrecision = '';
|
let datePrecision = '';
|
||||||
for (let i = 0; i < precision; i++)
|
for (let i = 0; i < Number(precision); i++)
|
||||||
datePrecision += i === 0 ? '.S' : 'S';
|
datePrecision += i === 0 ? '.S' : 'S';
|
||||||
|
|
||||||
return moment(val).isValid() ? moment(val).format(`YYYY-MM-DD HH:mm:ss${datePrecision}`) : val;
|
return moment(val).isValid() ? moment(val).format(`YYYY-MM-DD HH:mm:ss${datePrecision}`) : val;
|
||||||
|
|
Loading…
Reference in New Issue