Skip to content

Work on general purpose JSONB support #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Work on general purpose JSONB support #14

merged 1 commit into from
Oct 15, 2024

Conversation

coderdan
Copy link
Contributor

No description provided.

SELECT * FROM users WHERE attrs @> '{"field": "value"}`;
```

#### `cs_ste_term_v1(val JSONB, epath TEXT)`
Copy link
Contributor

@CDThomas CDThomas Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make epath here json/jsonb as well? The motivation is that the JSON value would include all the info needed for generating the MAC so that Proxy doesn't need to sort out the table, column, etc based by looking at anything other than the param or literal used for the arg.

I think that we could aim to target text in SM2, but using JSON here similar to how encryption already works for other EQL functions would simplify the Proxy (MLP) logic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, what's the return type of cs_ste_term_v1 ? ore_64_8_v1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think for now that makes the most sense. I considered adding a variant of cs_ste_term_v1 which also takes a term type so we can handle other types of index terms but for now this should be enough. Does that sounds reasonable?

}
```

`$.firstName` returns `[John]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the returned value in an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to keep the same behaviour as standard JSONPath.
Screenshot 2024-10-15 at 2 10 53 PM

I used https://jsonpath.com/

Comment on lines +240 to +256
```rb
# Serialize a JSONB value bound to the users table column
term = User::ENCRYPTED_JSONB.serialize({field: "value"})
User.where("cs_ste_vec_v1(attrs) @> cs_ste_vec_v1(?)", term)
```

Which will execute on the server as:

```sql
SELECT * FROM users WHERE cs_ste_vec_v1(attrs) @> '53T8dtvW4HhofDp9BJnUkw';
```

And is the EQL equivalent of the following plaintext query.

```sql
SELECT * FROM users WHERE attrs @> '{"field": "value"}`;
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this framing

@coderdan
Copy link
Contributor Author

Note to self: add the things that the simplified, eJSON path doesn't support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants