Skip to content
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

fix: operator 'or' and escape character not working (#6705) #6708

Merged
merged 5 commits into from
Mar 24, 2025

Conversation

enokryeziu
Copy link

@enokryeziu enokryeziu commented Mar 12, 2025

For more details this is the issue:

#6705

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

What is the new behavior?

fixes (issue)

Notes for reviewers

@enokryeziu enokryeziu requested a review from a team as a code owner March 12, 2025 15:45
Copy link

changeset-bot bot commented Mar 12, 2025

⚠️ No Changeset found

Latest commit: 4a783c8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

netlify bot commented Mar 12, 2025

Deploy Preview for refine-doc-live-previews ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 4a783c8
🔍 Latest deploy log https://app.netlify.com/sites/refine-doc-live-previews/deploys/67e11287823139000804f91f
😎 Deploy Preview https://deploy-preview-6708--refine-doc-live-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@enokryeziu enokryeziu changed the title Fix the problem with or operator and contains to escape characters fix: operator 'or' and and escape character not working #6705 Mar 13, 2025
@@ -2008,7 +2008,7 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
select: "%2A",
offset: "0",
limit: "10",
or: "%28title.ilike.%25Black+Psorotichia%25%2Ccontent.ilike.%25Sed+sagittis%25%29",
or: "%28title.ilike.%22%25Black+Psorotichia%25%22%2Ccontent.ilike.%22%25Sed+sagittis%25%22%29",
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you are changing the mock manually.

To make tests truly meaningful, we should record them using mock. You can uncomment here to record responses. After that, nock will print the responses in the console so we can copy and use them.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for my ignorance this is my first time, so what I should do is uncomment that part of the code and then run:
pnpm test -- --scope @refinedev/supabase --verbose which will generate something in console to then replace that in the mock file or just uncomment and push the code?

Because I did try to uncomment and run the test locally but many tests failed

Copy link
Member

Choose a reason for hiding this comment

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

Yes, because when we enable nock.recorder.rec();, requests go to the database. Unfortunately, our Supabase database has changed a lot since this test was written (mutation test failures are due to auth policies), and updating all nocks would take too much time.

I ran only the getList tests using this command:

pnpm test -- --scope @refinedev/supabase -- --testPathPattern=packages/supabase/test/getList/index.spec.ts

I ignored all tests except "contains operator should work correctly with or" because only its logic has changed. The nock response I got is:

nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
  encodedQueryParams: true,
})
  .get("/rest/v1/posts")
  .query({
    select: "%2A",
    offset: "0",
    limit: "10",
    or: "%28title.ilike.%22%25Black%20Psorotichia%25%22%2Ccontent.ilike.%22%25Sed%20sagittis%25%22%29",
  })
  .reply(
    200,
    [
      {
        id: 1,
        title: "Black Psorotichia Lichen",
        slug: "61a31089-c85d-48a0-a4be-d5dce5c96b6a",
        createdAt: "2024-04-24T13:20:10.200327+00:00",
        content:
          "Integer tincidunt ante vel ipsum. Praesent blandit lacinia erat. Vestibulum sed magna at nunc commodo placerat.\n\nPraesent blandit. Nam nulla. Integer pede justo, lacinia eget, tincidunt eget, tempus vel, pede.\n\nMorbi porttitor lorem id ligula. Suspendisse ornare consequat lectus. In est risus, auctor sed, tristique in, tempus sit amet, sem.",
        categoryId: 7,
        images: null,
      },
      {
        id: 13,
        title: "Dust Lichen",
        slug: "ca038c02-0c6f-417b-aaf8-6f51b777d1f5",
        createdAt: "2024-04-24T13:20:10.200327+00:00",
        content:
          "Fusce posuere felis sed lacus. Morbi sem mauris, laoreet ut, rhoncus aliquet, pulvinar sed, nisl. Nunc rhoncus dui vel sem.\n\nSed sagittis. Nam congue, risus semper porta volutpat, quam pede lobortis ligula, sit amet eleifend pede libero quis orci. Nullam molestie nibh in lectus.",
        categoryId: 7,
        images: null,
      },
    ],
    [
      "Date",
      "Mon, 17 Mar 2025 10:29:52 GMT",
      "Content-Type",
      "application/json; charset=utf-8",
      "Transfer-Encoding",
      "chunked",
      "Connection",
      "close",
      "Content-Range",
      "0-1/2",
      "CF-Ray",
      "921bcfca7bad925f-FRA",
      "CF-Cache-Status",
      "DYNAMIC",
      "Content-Location",
      "/posts?limit=10&offset=0&or=%28title.ilike.%22%25Black%20Psorotichia%25%22%2Ccontent.ilike.%22%25Sed%20sagittis%25%22%29&select=%2A",
      "Strict-Transport-Security",
      "max-age=31536000; includeSubDomains; preload",
      "Vary",
      "Accept-Encoding",
      "content-profile",
      "public",
      "preference-applied",
      "count=exact",
      "sb-gateway-version",
      "1",
      "sb-project-ref",
      "iwdfzvfqbtokqetmbmbp",
      "X-Content-Type-Options",
      "nosniff",
      "x-envoy-attempt-count",
      "1",
      "x-envoy-upstream-service-time",
      "18",
      "Server",
      "cloudflare",
      "alt-svc",
      'h3=":443"; ma=86400',
    ],
  );

I was going to push this to the PR, but I got a permission denied error.

Copy link
Author

@enokryeziu enokryeziu Mar 17, 2025

Choose a reason for hiding this comment

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

Okay thanks for your help I will keep this in mind for feature requests. I used the response that you got and pushed the commit.

@alicanerdurmaz alicanerdurmaz added this to the March 2025 Release milestone Mar 13, 2025
@enokryeziu enokryeziu changed the title fix: operator 'or' and and escape character not working #6705 fix: operator 'or' and escape character not working (#6705) Mar 13, 2025
@alicanerdurmaz alicanerdurmaz changed the base branch from main to next March 18, 2025 06:51
@alicanerdurmaz alicanerdurmaz requested a review from a team as a code owner March 18, 2025 06:51
@alicanerdurmaz alicanerdurmaz linked an issue Mar 18, 2025 that may be closed by this pull request
@alicanerdurmaz alicanerdurmaz merged commit 8d8cddb into refinedev:next Mar 24, 2025
4 checks passed
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.

[BUG] the input having ',' is breaking the filter OR
3 participants