The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/mysql/sqlUtil.test.ts

18 lines
884 B

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);
});
});