[ASK] Using Query Builder's ".clone()" correctly


I’m still kinda confused with cloning a query builder, using .clone().
i have this query of a lucid model using builder (I’m using REPL):

> const Permission = use('App/Models/Permission')
> const query = Permission.query().where('is_deleted',0)
> const q1 = query.clone().where('is_enabled', 1).toString()
> const q2 = query.clone().toString()
> q1
'select * from [m_permission] where [is_deleted] = 0 and [is_enabled] = 1'
> q2
'select * from [m_permission] where [is_deleted] = 0 and [is_enabled] = 1'

i wanted to run 2 instance of query,
where the seconds query run the same as first one,
but omitting the [is_enabled] = 1

By using .clone(),
Isn’t q2 supposed to be like this:

select * from [m_permission] where [is_deleted] = 0

invoking the and [is_enabled] = 1.

or am I missing the logic?


Hi, I am also experiencing similar problems with using .clone(). Did you fix it? Can share the way for me.

Look forward to receiving feedback.