analyzer.opts.schema.test.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. var Analyzer = require('../../../index').query.analyzer;
  2. var tokenize = require('../../support/tokenize');
  3. var assert = require('assert');
  4. describe('Analyzer ::', function() {
  5. describe('OPTS', function() {
  6. it('should generate a valid group when a SCHEMA is used', function() {
  7. var tokens = tokenize({
  8. select: ['title', 'author', 'year'],
  9. from: 'books',
  10. opts: {
  11. schema: 'foo'
  12. }
  13. });
  14. var result = Analyzer(tokens);
  15. assert.deepEqual(result, [
  16. [
  17. { type: 'IDENTIFIER', value: 'SELECT' },
  18. { type: 'VALUE', value: 'title' }
  19. ],
  20. [
  21. { type: 'IDENTIFIER', value: 'SELECT' },
  22. { type: 'VALUE', value: 'author' }
  23. ],
  24. [
  25. { type: 'IDENTIFIER', value: 'SELECT' },
  26. { type: 'VALUE', value: 'year' }
  27. ],
  28. [
  29. { type: 'IDENTIFIER', value: 'FROM' },
  30. { type: 'VALUE', value: 'books' }
  31. ],
  32. [
  33. { type: 'IDENTIFIER', value: 'SCHEMA' },
  34. { type: 'VALUE', value: 'foo' }
  35. ]
  36. ]);
  37. });
  38. });
  39. });