Bug 155519 - Add simple SQL quoter
Add simple SQL quoter
Status: NEW
Product: db
Classification: Unclassified
Component: Code
6.x
All All
: P3 (vote)
: TBD
Assigned To: Libor Fischmeistr
issues@db
: API, API_REVIEW_FAST
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-16 04:50 UTC by David Vancouvering
Modified: 2013-09-04 08:22 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Patch file for changes to API (10.45 KB, text/plain)
2008-12-16 05:05 UTC, David Vancouvering
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Vancouvering 2008-12-16 04:50:34 UTC
Currently there is a Quoter API that lets you create a quoter for SQL statements.  The API has a factory that lets you
create a Quoter from DatabaseMetaData.  This doesn't always work, as you don't always have DatabaseMetaData available. 
This enhancment is to provide for a simple quoter that does the "standard" quoting algorithm: quote anything that has
characters that are not in the set A-Z, a-z and _
Comment 1 David Vancouvering 2008-12-16 04:51:20 UTC
Please review, attachment will follow.
Comment 2 David Vancouvering 2008-12-16 05:05:07 UTC
Created attachment 74997 [details]
Patch file for changes to API
Comment 3 _ ahimanikya 2008-12-16 07:23:59 UTC
This is very useful. It will be nice if you can allow setting keywords (array of string or a list) that will be very
useful; It will be even better, if you can define base keyword and allow user to add more through API, before they
invoke quoteIfrequired()

I used these base keyword somewhere else, putting it here for reference:

String[] syntax =
                       {
                   "ABSOLUTE", "ACTION", "ADD", "ALL", "ALLOCATE", "ALTER", // NOI18N
                   "AND", "ANY", "ARE", "AS", "ASC", "ASSERTION", "AT", // NOI18N
                   "AUTHORIZATION", "AVG", "BEGIN", "BETWEEN", "BIT", // NOI18N
                   "BIT_LENGTH", "BOTH", "BY", "CASCADE", "CASCADED", "CASE", // NOI18N
                   "CAST", "CATALOG", "CHAR", "CHARACTER", "CHAR_LENGTH", // NOI18N
                   "CHARACTER_LENGTH", "CHECK", "CLOSE", "COALESCE", "COLLATE", // NOI18N
                   "COLLATION", "COLUMN", "COMMIT", "CONNECT", "CONNECTION", // NOI18N
                   "CONSTRAINT", "CONSTRAINTS", "CONTINUE", "CONVERT", // NOI18N
                   "CORRESPONDING", "COUNT", "CREATE", "CROSS", "CURRENT", // NOI18N
                   "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", // NOI18N
                   "CURRENT_USER", "CURSOR", "DATE", "DAY", "DEALLOCATE", "DEC", // NOI18N
                   "DECIMAL", "DECLARE", "DEFAULT", "DEFERRABLE", "DEFERRED", // NOI18N
                   "DELETE", "DESC", "DESCRIBE", "DESCRIPTOR", "DIAGNOSTICS", // NOI18N
                   "DISCONNECT", "DISTINCT", "DOMAIN", "DOUBLE", "DROP", "ELSE", // NOI18N
                   "END", "END-EXEC", "ESCAPE", "EXCEPT", "EXCEPTION", "EXEC", // NOI18N
                   "EXECUTE", "EXISTS", "EXTERNAL", "EXTRACT", "FALSE", "FETCH", // NOI18N
                   "FIRST", "FLOAT", "FOR", "FOREIGN", "FOUND", "FROM", "FULL", // NOI18N
                   "GET", "GLOBAL", "GO", "GOTO", "GRANT", "GROUP", "HAVING", // NOI18N
                   "HOUR", "IDENTITY", "IMMEDIATE", "IN", "INDICATOR", // NOI18N
                   "INITIALLY", "INNER", "INPUT", "INSENSITIVE", "INSERT", "INT", // NOI18N
                   "INTEGER", "INTERSECT", "INTERVAL", "INTO", "IS", "ISOLATION", // NOI18N
                   "JOIN", "KEY", "LANGUAGE", "LAST", "LEADING", "LEFT", "LEVEL", // NOI18N
                   "LIKE", "LOCAL", "LOWER", "MATCH", "MAX", "MIN", "MINUTE", // NOI18N
                   "MODULE", "MONTH", "NAMES", "NATIONAL", "NATURAL", "NCHAR", // NOI18N
                   "NEXT", "NO", "NOT", "NULL", "NULLIF", "NUMERIC", // NOI18N
                   "OCTET_LENGTH", "OF", "ON", "ONLY", "OPEN", "OPTION", "OR", // NOI18N
                   "ORDER", "OUTER", "OUTPUT", "OVERLAPS", "PAD", "PARTIAL", // NOI18N
                   "POSITION", "PRECISION", "PREPARE", "PRESERVE", "PRIMARY", // NOI18N
                   "PRIOR", "PRIVILEGES", "PROCEDURE", "PUBLIC", "READ", "REAL", // NOI18N
                   "REFERENCES", "RELATIVE", "RESTRICT", "REVOKE", "RIGHT", // NOI18N
                   "ROLLBACK", "ROWS", "SCHEMA", "SCROLL", "SECOND", "SECTION", // NOI18N
                   "SELECT", "SESSION", "SESSION_USER", "SET", "SIZE", "SMALLINT", // NOI18N
                   "SOME", "SPACE", "SQL", "SQLCODE", "SQLERROR", "SQLSTATE", // NOI18N
                   "SUBSTRING", "SUM", "SYSTEM_USER", "TABLE", "TEMPORARY", // NOI18N
                   "THEN", "TIME", "TIMESTAMP", "TIMEZONE_HOUR", // NOI18N
                   "TIMEZONE_MINUTE", "TO", "TRAILING", "TRANSACTION", // NOI18N
                   "TRANSLATE", "TRANSLATION", "TRIM", "TRUE", "UNION", "UNIQUE", // NOI18N
                   "UNKNOWN", "UPDATE", "UPPER", "USAGE", "USER", "USING", "VALUE", // NOI18N
                   "VALUES", "VARCHAR", "VARYING", "VIEW", "WHEN", "WHENEVER", // NOI18N
                   "WHERE", "WITH", "WORK", "WRITE", "YEAR", "ZONE"
               }; 

Also See http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html
Comment 4 David Vancouvering 2008-12-16 18:54:17 UTC
Hi, Ahi.  Great ideas, but beyond the scope of this API change.  Can you please log a separate enhancement request? 
It's related to the issue where we should quote identifiers that are valid SQL keywords.
Comment 5 Jiri Rechtacek 2009-10-16 14:12:15 UTC
Reassigned to new owner.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo