@malloydata/malloy 0.0.183-dev240916205710 → 0.0.183-dev240917170343

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -263,8 +263,13 @@ function equality(fs, left, op, right) {
263
263
  case '~':
264
264
  case '!~': {
265
265
  if (lhs.dataType !== 'string' || rhs.dataType !== 'string') {
266
- const regexCmp = regexEqual(lhs, rhs);
267
- if (regexCmp === undefined) {
266
+ let regexCmp = regexEqual(lhs, rhs);
267
+ if (regexCmp) {
268
+ if (op[0] === '!') {
269
+ regexCmp = { node: 'not', e: { ...regexCmp } };
270
+ }
271
+ }
272
+ else {
268
273
  throw new TypeMismatch("Incompatible types for match('~') operator");
269
274
  }
270
275
  value = regexCmp;
@@ -112,6 +112,12 @@ describe('expressions', () => {
112
112
  test('not match', () => {
113
113
  expect("'forty-two' !~ 'fifty-four'").compilesTo('{"forty-two" !like "fifty-four"}');
114
114
  });
115
+ test('regexp-match', () => {
116
+ expect("'forty-two' ~ r'fifty-four'").compilesTo('{"forty-two" regex-match /fifty-four/}');
117
+ });
118
+ test('not regexp-match', () => {
119
+ expect("'forty-two' !~ r'fifty-four'").compilesTo('{not {"forty-two" regex-match /fifty-four/}}');
120
+ });
115
121
  test('apply as equality', () => {
116
122
  expect("'forty-two' ? 'fifty-four'").compilesTo('{"forty-two" = "fifty-four"}');
117
123
  });
@@ -161,6 +161,8 @@ function eToStr(e, symbols) {
161
161
  return `"${e.literal}"`;
162
162
  case 'timeLiteral':
163
163
  return `@${e.literal}`;
164
+ case 'regexpLiteral':
165
+ return `/${e.literal}/`;
164
166
  case 'trunc':
165
167
  return `{timeTrunc-${e.units} ${subExpr(e.e)}}`;
166
168
  case 'delta':
@@ -168,6 +170,8 @@ function eToStr(e, symbols) {
168
170
  case 'true':
169
171
  case 'false':
170
172
  return e.node;
173
+ case 'regexpMatch':
174
+ return `{${subExpr(e.kids.expr)} regex-match ${subExpr(e.kids.regex)}}`;
171
175
  }
172
176
  if ((0, model_1.exprHasKids)(e) && e.kids['left'] && e.kids['right']) {
173
177
  return `{${subExpr(e.kids['left'])} ${e.node} ${subExpr(e.kids['right'])}}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.183-dev240916205710",
3
+ "version": "0.0.183-dev240917170343",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",