Skip to content

Commit

Permalink
Remove check for index decorator parameter
Browse files Browse the repository at this point in the history
Removes check that the specific string "full-text" is the only allowable parameter to the `@index` decorator. New behavior is to allow any string to be passed through to the schema. Invalid values in the schema will throw at runtime, alerting user to possible errors.
  • Loading branch information
atdyer committed Nov 6, 2023
1 parent 1cb9199 commit b6e919f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
10 changes: 0 additions & 10 deletions packages/babel-plugin/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,6 @@ describe("Babel plugin", () => {
expect((parsedSchema?.properties.name as PropertySchema).indexed).toBeUndefined();
});

it('ignores `@index()` decorators with invalid parameters', () => {
const transformCode = transform({
source: `import Realm, { Types, BSON, List, Set, Dictionary, Mixed } from "realm";
export class Person extends Realm.Object { @Realm.index("fulltext") name: Realm.Types.String; }`,
});
const parsedSchema = extractSchema(transformCode);

expect((parsedSchema?.properties.name as PropertySchema).indexed).toBeUndefined();
})

it('removes `@index("full-text")` decorators from the source', () => {
const transformCode = transformProperty(`@index("full-text") name: Realm.Types.String;`);
// This is what Babel outputs for transformed decorators
Expand Down
1 change: 0 additions & 1 deletion packages/babel-plugin/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ function visitRealmClassProperty(path: NodePath<types.ClassProperty>) {
const indexCall =
indexDecoratorCall
&& types.isStringLiteral(indexDecoratorCall.callExpression.arguments[0])
&& indexDecoratorCall.callExpression.arguments[0].value === 'full-text'
? indexDecoratorCall.callExpression.arguments[0].value
: undefined;

Expand Down

0 comments on commit b6e919f

Please sign in to comment.