This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 204103 - Code completion in sql strings doesn't work if the query contains non standard sql commands
Summary: Code completion in sql strings doesn't work if the query contains non standar...
Status: NEW
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Libor Fischmeistr
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-22 17:34 UTC by paolosca
Modified: 2013-08-01 12:52 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description paolosca 2011-10-22 17:34:38 UTC
In example in the following postgres query

$query = "
set DATESTYLE to 'Postgres,European';
select * from 
";

I place the caret after "from" and press ctrl+space but nothing happens.

If I remove "set DATESTYLE to 'Postgres,European';" then code completion works fine:

$query = "
select * from 
";

I believe it's because "set DATESTYLE to 'Postgres,European';" is not recognized.
 
Perhaps the when editing a query made in more parts code completion should ignore any text before a semicolon (including the semi colon itself).

In the following examples I will use | as the caret and I will close the text that should be ignored within square brackets:

$query = "[
set DATESTYLE to 'Postgres,European';]
select * from |
";

$query = "[
select field_a from table_a;]
select * from |
";

Regards,

Paolo
Comment 1 Tomas Mysik 2011-10-24 06:42:23 UTC
Editor area. Or maybe databases? Please evaluate.

Thanks.
Comment 2 Ondrej Brejla 2011-10-31 10:07:12 UTC
It's not so simple. There is a method, in the PHP part of implementation, which checks possible SQL statements. It's considered by the start of a string. If the string, where the CC is invoked, starts with "select, insert, update, delete, or drop", it's considered as "possible sql statement".

But I can't simply add "set" as another keyword, because it is not supported by DB infrastracture too :) So I have to extract the exact statement, where the carret is, trim it out of that whole string (where are another statements too) and pass it to the DB infrastructure for CC...

You can simply workaround it by dividing SQL statements into separate strings.
Comment 3 paolosca 2011-11-04 08:29:55 UTC
I was trying to find a workaround for this and I noticed that the database code completion doesn't work even if the "set" line is commented as in the following example:

$query = "
-- set DATESTYLE to 'Postgres,European';
select * from 
";
Comment 4 Ondrej Brejla 2011-11-04 08:54:34 UTC
Yes, it can't. It works only with insert, update, delete, select, drop at the start of the string. And yes, it's hardcoded there...no evaluation about comments is used, it simply checks String.startsWith() at the whole string. It's really dummy implementation :)
Comment 5 Ondrej Brejla 2012-04-23 14:34:53 UTC
I think that the "SET" command should be supported by NetBeans DB support at first.