I'm not sure when this stopped working, but I'm using Objection v2.1.3 and when I call MyModel.query().toString() I get [object QueryBuilder] (same with .toSql()). Previously I would get a string of SQL. This is in an older part of my codebase that was written early last year sometime. Has the usage of toString/toSql changed since then? I'm looking at the documentation on the site and I don't see where I could be going wrong here. Any help would be very much appreciated. Thanks!
It was removed in 2.0. See the list of breaking changes. You can use toKnexQuery().toSQL()
Thanks @koskimas. It would be cool if that was noted in the documentation :thumbsup:
It is.
https://vincit.github.io/objection.js/release-notes/migration.html#querybuilder-tostring-and-querybuilder-tosql-have-been-removed
Yeah, I found that after your comment yesterday, but I'm talking about these:
https://vincit.github.io/objection.js/api/query-builder/other-methods.html#tostring
https://vincit.github.io/objection.js/api/query-builder/other-methods.html#tosql
Those are what I was looking at originally and was very confused as to why it wasn't working. It would be very helpful if there was a note there, and especially if that includes the migration link you just referenced.
Oh damn! I'll fix those asap. I had no idea those were outdated. Thanks for pointing this out.
Most helpful comment
Oh damn! I'll fix those asap. I had no idea those were outdated. Thanks for pointing this out.