mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-17 04:00:48 +01:00
feat(PostgreSQL): UUID random generation option on UUID fields, closes #424
This commit is contained in:
parent
86e4c1d58f
commit
a521274d01
@ -140,7 +140,7 @@ export default class {
|
||||
{ name: 'arrayElement', group: 'random', types: ['string'] },
|
||||
{ name: 'arrayElements', group: 'random', types: ['string'] },
|
||||
{ name: 'objectElement', group: 'random', types: ['string'] },
|
||||
{ name: 'uuid', group: 'random', types: ['string'] },
|
||||
{ name: 'uuid', group: 'random', types: ['string', 'uuid'] },
|
||||
{ name: 'boolean', group: 'random', types: ['string'] },
|
||||
{ name: 'word', group: 'random', types: ['string'] },
|
||||
{ name: 'words', group: 'random', types: ['string'] },
|
||||
|
@ -86,6 +86,14 @@ export const BIT = [
|
||||
'BIT VARYING'
|
||||
];
|
||||
|
||||
export const BINARY = [
|
||||
'BINARY'
|
||||
];
|
||||
|
||||
export const UUID = [
|
||||
'UUID'
|
||||
];
|
||||
|
||||
export const SPATIAL = [
|
||||
'POINT',
|
||||
'LINESTRING',
|
||||
|
@ -87,7 +87,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, PropType, Ref, ref, watch } from 'vue';
|
||||
import { TEXT, LONG_TEXT, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
||||
import { TEXT, LONG_TEXT, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT, UUID } from 'common/fieldTypes';
|
||||
import BaseUploadInput from '@/components/BaseUploadInput.vue';
|
||||
import ForeignKeySelect from '@/components/ForeignKeySelect.vue';
|
||||
import FakerMethods from 'common/FakerMethods';
|
||||
@ -126,6 +126,8 @@ const fakerGroups = computed(() => {
|
||||
localType.value = 'datetime';
|
||||
else if (TIME.includes(props.type))
|
||||
localType.value = 'time';
|
||||
else if (UUID.includes(props.type))
|
||||
localType.value = 'uuid';
|
||||
else
|
||||
localType.value = 'none';
|
||||
|
||||
|
@ -212,6 +212,7 @@ import {
|
||||
DATETIME,
|
||||
BLOB,
|
||||
BIT,
|
||||
BINARY,
|
||||
HAS_TIMEZONE,
|
||||
SPATIAL,
|
||||
IS_MULTI_SPATIAL
|
||||
@ -379,6 +380,9 @@ const editON = async (field: string) => {
|
||||
|
||||
const content = props.row[field];
|
||||
const type = props.fields[field].type.toUpperCase();
|
||||
|
||||
if (BINARY.includes(type)) return;
|
||||
|
||||
originalContent.value = typeFormat(content, type, props.fields[field].length);
|
||||
editingType.value = type;
|
||||
editingField.value = field;
|
||||
@ -582,6 +586,9 @@ const typeFormat = (val: string | number | Date | number[], type: string, precis
|
||||
return parseInt(bitString).toString().padStart(Number(precision), '0');
|
||||
}
|
||||
|
||||
if (BINARY.includes(type))
|
||||
return Buffer.from(val as number[]).toString('hex');
|
||||
|
||||
if (ARRAY.includes(type)) {
|
||||
if (Array.isArray(val))
|
||||
return JSON.stringify(val).replaceAll('[', '{').replaceAll(']', '}');
|
||||
|
Loading…
x
Reference in New Issue
Block a user