analyzer.update.test.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. var Analyzer = require('../../../index').query.analyzer;
  2. var tokenize = require('../../support/tokenize');
  3. var assert = require('assert');
  4. describe('Analyzer ::', function() {
  5. describe('UPDATE statements', function() {
  6. it('should generate a valid group for UPDATE statements', function() {
  7. var tokens = tokenize({
  8. update: {
  9. status: 'archived'
  10. },
  11. where: {
  12. and: [
  13. {
  14. publishedDate: {
  15. '>': 2000
  16. }
  17. }
  18. ]
  19. },
  20. using: 'books'
  21. });
  22. var result = Analyzer(tokens);
  23. assert.deepEqual(result, [
  24. [
  25. { type: 'IDENTIFIER', value: 'UPDATE' },
  26. { type: 'KEY', value: 'status' },
  27. { type: 'VALUE', value: 'archived' }
  28. ],
  29. [
  30. { type: 'IDENTIFIER', value: 'WHERE' },
  31. { type: 'CONDITION', value: 'AND' },
  32. [
  33. { type: 'KEY', value: 'publishedDate' },
  34. { type: 'OPERATOR', value: '>' },
  35. { type: 'VALUE', value: 2000 }
  36. ]
  37. ],
  38. [
  39. { type: 'IDENTIFIER', value: 'USING' },
  40. { type: 'VALUE', value: 'books' }
  41. ]
  42. ]);
  43. });
  44. });
  45. });