How to fix <statement> expected, got 'NOT' warning.

Answered

I got the following error message. "<statement> expected, got 'NOT'". The code itself works fine.


What am I doing wrong? I'm using PostgreSQL and the SQL is recognized as a PostgreSQL query.
(I'm not how to confirm it. At least the tip shows that is a PostgreSQL fragment.)

 

This is my environment

----------------

RubyMine 2020.2.2
Build #RM-202.7319.53, built on September 15, 2020
Runtime version: 11.0.8+10-b944.31 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.6
Non-Bundled Plugins: de.ax.powermode, com.wix.eslint, org.jetbrains.plugins.vue, AngularJS, net.ashald.envfile, ru.adelf.idea.dotenv

0
5 comments

could you please share code block with full query and <<-SQL usage?

0
Avatar
Permanently deleted user

This code is used for select `Company` models where that have no `QuickResource` model.

class Company < ApplicationRecord
has_many :quick_resources
scope :has_no_quick_resource, -> {
where(<<-SQL)
NOT EXISTS (SELECT * FROM quick_resources q WHERE q.company_id = companies.id)
SQL
}
end
class QuickResource < ApplicationRecord
belongs_to :company
end
0

Looks like a bug. I've created the issue on our tracker, please follow and vote.

0
Avatar
Permanently deleted user

Thanks! I've voted up.

0
Avatar
Permanently deleted user

A typical if () statement looks like this. Depending on what you are checking for, the else if and else blocks may not be needed. Note how the { }( ) and ; are used. If you are searching for an article that can help you with the app development must visit spdload.com.

0

Please sign in to leave a comment.