mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 09:05:45 -06:00
* SQL: toRawSQL required and escape table * Fix autocomplete for MySQL * Change the way we escape for builder * Rework escape ident to be smart instead * Fix A11y for alias * Add first e2e test * Add test for code editor * Add doc * Review comments * Move functions to sqlUtil
19 lines
884 B
TypeScript
19 lines
884 B
TypeScript
import { isValidIdentifier } from './sqlUtil';
|
|
|
|
describe('isValidIdentifier', () => {
|
|
test.each([
|
|
{ value: 'and', expected: false }, // Reserved keyword
|
|
{ value: '1name', expected: false }, // Starts with value
|
|
{ value: 'my-sql', expected: false }, // Contains not permitted character
|
|
{ value: '$id', expected: false }, // $ sign shouldn't be the first character
|
|
{ value: 'my sql', expected: false }, // Whitespace is not permitted
|
|
{ value: 'mysql ', expected: false }, // Whitespace is not permitted at the end
|
|
{ value: ' mysql', expected: false }, // Whitespace is not permitted
|
|
{ value: 'id$', expected: true },
|
|
{ value: 'myIdentifier', expected: true },
|
|
{ value: 'table_name', expected: true },
|
|
])('should return $expected when value is $value', ({ value, expected }) => {
|
|
expect(isValidIdentifier(value)).toBe(expected);
|
|
});
|
|
});
|