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

Clone method removes preloads #1033

Closed
enixsoft opened this issue May 30, 2024 · 3 comments · Fixed by #1050
Closed

Clone method removes preloads #1033

enixsoft opened this issue May 30, 2024 · 3 comments · Fixed by #1050
Assignees

Comments

@enixsoft
Copy link

enixsoft commented May 30, 2024

Package version

├── @adonisjs/assembler@7.6.1
├── @adonisjs/core@6.9.0
├── @adonisjs/eslint-config@1.3.0
├── @adonisjs/lucid@20.6.0
├── @adonisjs/prettier-config@1.3.0
├── @adonisjs/tsconfig@1.3.0
├── @japa/assert@3.0.0
├── @japa/plugin-adonisjs@3.0.1
├── @japa/runner@3.1.4
├── @swc/core@1.5.24
├── @types/luxon@3.4.2
├── @types/node@20.12.13
├── eslint@8.57.0
├── hot-hook@0.2.6
├── luxon@3.4.4
├── pg@8.11.5
├── pino-pretty@11.1.0
├── prettier@3.2.5
├── reflect-metadata@0.2.2
├── ts-node@10.9.2
└── typescript@5.4.5

Describe the bug

Hello. I have found a possible bug when using clone() method on ModelQueryBuilderContract which has a preload. The cloned query will not execute the preload query. I am using PostgreSQL 15.1 database.

const postQuery = Post.query().preload('user')

const clonedPostQuery = postQuery.clone()

return { post: await postQuery, clonedPost: await clonedPostQuery }

The result is:

{
  "post":[
     {
        "id":1,
        "userId":1,
        "title":"Test",
        "createdAt":"2024-05-30T14:11:18.505+00:00",
        "updatedAt":"2024-05-30T14:11:18.505+00:00",
        "user":{
           "id":1,
           "name":"Test",
           "createdAt":"2024-05-30T14:11:08.784+00:00",
           "updatedAt":"2024-05-30T14:11:08.784+00:00"
        }
     }
  ],
  "clonedPost":[
     {
        "id":1,
        "userId":1,
        "title":"Test",
        "createdAt":"2024-05-30T14:11:18.505+00:00",
        "updatedAt":"2024-05-30T14:11:18.505+00:00"
     }
  ]
}
@MaximeMRF
Copy link
Contributor

I have the same problem

@RomainLanz
Copy link
Member

Could you please create a pull request with a failing test?

@adamcikado
Copy link
Contributor

@RomainLanz added

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 a pull request may close this issue.

4 participants