Skip to content

Commit

Permalink
feat: support uppper case 'POLYGON'
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Mar 24, 2021
1 parent 0bcca2f commit 752c6e1
Show file tree
Hide file tree
Showing 10 changed files with 1,513 additions and 2,724 deletions.
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
'transform': {
'.(js|ts|tsx)': 'ts-jest'
'.(ts|tsx)': 'ts-jest'
},
'testTimeout': 30 * 1000,
'collectCoverageFrom': [
Expand All @@ -16,5 +16,6 @@ module.exports = {
],
'modulePathIgnorePatterns': [
'<rootDir>/lib'
]
],
"testEnvironment": "node"
};
4,139 changes: 1,447 additions & 2,692 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@
},
"devDependencies": {
"@odata/metadata": "^0.1.14",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.2",
"@typescript-eslint/eslint-plugin": "^4.2.0",
"@typescript-eslint/parser": "^4.2.0",
"eslint": "^7.9.0",
"jest": "^26.4.2",
"@types/jest": "^26.0.21",
"@types/node": "^14.14.35",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"eslint": "^7.22.0",
"jest": "^26.6.3",
"rimraf": "^3.0.2",
"standard-version": "^9.0.0",
"ts-jest": "^26.4.0",
"typescript": "^4.0.3"
"standard-version": "^9.1.1",
"ts-jest": "^26.5.4",
"typescript": "^4.2.3"
},
"dependencies": {
"@newdash/newdash": "^5.13.0"
"@newdash/newdash": "^5.17.1"
},
"keywords": [
"odata",
Expand Down
3 changes: 2 additions & 1 deletion src/primitiveLiteral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ export function pointLiteral(value: SourceArray, index: number): Lexer.Token {
return Lexer.tokenize(value, start, data.next, data, Lexer.TokenType.Literal);
}
export function polygonLiteral(value: SourceArray, index: number): Lexer.Token {
if (!Utils.equals(value, index, 'Polygon')) { return; }
if (!(Utils.equals(value, index, 'Polygon') || Utils.equals(value, index, 'POLYGON'))) { return; }

const start = index;
index += 7;

Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions test/issue.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defaultParser } from '../src';

describe('Issue Related Test Suite', () => {

it('should support paser uri with geography - Polygon', () => {

const t = defaultParser.odataUri("/Products?$filter=geo.intersects(Location, geography'SRID=12345;Polygon((-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534))')");
expect(t).not.toBeUndefined();

});

it('should support paser uri with geography - POLYGON', () => {

const t = defaultParser.odataUri("/Products?$filter=geo.intersects(Location, geography'SRID=12345;POLYGON((-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534))')");
expect(t).not.toBeUndefined();

});
});
19 changes: 0 additions & 19 deletions test/odata-uri.spec.js

This file was deleted.

19 changes: 19 additions & 0 deletions test/odata-uri.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { ServiceMetadata } from '@odata/metadata';
import { defaultParser } from '../src';


describe('OData URI Test Suite', () => {

const schoolMeta = ServiceMetadata.processMetadataJson(require('./resources/school.edmx.json'));

it('should support parser uri', () => {

defaultParser.odataUri('/Categories?$skip=30');
defaultParser.odataUri('/Categories(10)?$expand=A,C&$select=D,E');
const ast = defaultParser.odataUri('/Classes?$expand=students/student', { metadata: schoolMeta.edmx });

expect(ast).not.toBeUndefined();

});

});
File renamed without changes.
14 changes: 14 additions & 0 deletions test/primitiveLiteral.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @ts-nocheck
import { defaultParser } from '../src';
import * as PrimitiveLiteral from '../src/primitiveLiteral';
import cases from './primitive-cases';

Expand Down Expand Up @@ -27,6 +28,19 @@ describe('Primitive literals from json', () => {
});
}
});

it('should support geography - Polygon', () => {
const t = defaultParser.literal("geography'SRID=12345;Polygon((-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534))'");
expect(t.value).toBe('Edm.GeographyPolygon');
expect(t).not.toBeUndefined();
});

it('should support geography - POLYGON', () => {
const t = defaultParser.literal("geography'SRID=12345;POLYGON((-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534,-127.89734578345 45.234534534))'");
expect(t.value).toBe('Edm.GeographyPolygon');
expect(t).not.toBeUndefined();
});

});

function getLiteralFunctionName(itemRule) {
Expand Down

0 comments on commit 752c6e1

Please sign in to comment.