Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix keyword in schema @common #25

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/assets/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { message } from 'antd';
import React from 'react';
import ReactDom from 'react-dom';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';

import App from './App';
import { store } from './store';

message.config({
maxCount: 1,
});
Comment on lines +9 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need also in explorer?

ReactDom.render(
<Provider store={store}>
<Router>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/utils/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _ from 'lodash';
import { keyWords } from '#assets/config/nebulaQL';

export const handleKeyword = (name: string) => {
return keyWords.includes(name) ? '`' + name + '`' : name;
return keyWords.includes(name.toLowerCase()) ? `\`${name}\`` : name;
};

export const handleVidStringName = (name: string, spaceVidType?: string) => {
Expand Down
56 changes: 28 additions & 28 deletions app/assets/utils/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const getExploreMatchGQL = (params: {
const wheres = _filters ? `AND ALL(l IN e WHERE ${_filters})` : '';
const gql = `MATCH p=(v)${
edgeDirection === 'incoming' ? '<-' : '-'
}[e${edgeTypes.map(edge => `:${edge}`).join('|')}${_step}]${
}[e${edgeTypes.map(edge => `:${handleKeyword(edge)}`).join('|')}${_step}]${
edgeDirection === 'outgoing' ? '->' : '-'
}(v2)
WHERE id(v) IN [${selectVertexes
Expand Down Expand Up @@ -198,40 +198,40 @@ export const getAlterGQL = (params: {
const date = config.fields
.map(item => {
const { name, type, value, fixedLength, allowNull, comment } = item;
const propertyName = handleKeyword(name);
if (action === 'DROP') {
return name;
} else {
let str = `${name} ${
type !== 'fixed_string'
? type
: type + `(${fixedLength ? item.fixedLength : ''})`
} ${allowNull ? 'NULL' : 'NOT NULL'}`;
if (value) {
switch (type) {
case 'string':
case 'fixed_string':
str += ` DEFAULT "${value}"`;
break;
case 'timestamp':
const timestampReg = /^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/;
str += timestampReg.test(value)
? ` DEFAULT "${value}"`
: ` DEFAULT ${value}`;
break;
default:
str += ` DEFAULT ${value}`;
}
}
if (comment) {
str += ` COMMENT "${comment}"`;
return propertyName;
}
let str = `${propertyName} ${
type !== 'fixed_string'
? type
: type + `(${fixedLength ? item.fixedLength : ''})`
} ${allowNull ? 'NULL' : 'NOT NULL'}`;
if (value) {
switch (type) {
case 'string':
case 'fixed_string':
str += ` DEFAULT "${value}"`;
break;
case 'timestamp':
const timestampReg = /^(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):(\d{2})$/;
str += timestampReg.test(value)
? ` DEFAULT "${value}"`
: ` DEFAULT ${value}`;
break;
default:
str += ` DEFAULT ${value}`;
}
return str;
}
if (comment) {
str += ` COMMENT "${comment}"`;
}
return str;
})
.join(', ');
content = `${action} (${date})`;
}
const gql = `ALTER ${type} ${name} ${content}`;
const gql = `ALTER ${type} ${handleKeyword(name)} ${content}`;
return gql;
};

Expand Down