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 166885 - PostgreSQL : can not update text entry when getPrecision() returns 0
Summary: PostgreSQL : can not update text entry when getPrecision() returns 0
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Jiri Rechtacek
URL: http://d.hatena.ne.jp/shin/20090611/p1
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-10 23:48 UTC by Masaki Katakai
Modified: 2010-04-14 10:22 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 Masaki Katakai 2009-06-10 23:48:24 UTC
Japanese community user kindly reported this issue. The entry of blog was
posted in Japanese but you can find what's wrong by screenshots.

  http://d.hatena.ne.jp/shin/20090611/p1

When getPrecision() returns 0 (e.g. in PostgreSQL), validate() of
DBReadWriteHelper.java is not working properly. When we try to update
text on DB editor (invoked by show data), it causes the following dialog.

 http://shin.cside.com/diary/2009/0611-04.png

It seems that the following codes are not correct.

db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java:

    public static Object validate(Object valueObj, DBColumn col) throws DBException {

                case Types.CHAR:
                case Types.VARCHAR:
                case Types.LONGVARCHAR:
                case -9:  //NVARCHAR
                case -8:  //ROWID
                case -15: //NCHAR
                    if (valueObj.toString().length() > col.getPrecision()) {
                        String colName = col.getQualifiedName(false);
                        String errMsg = "Too large data \'" + valueObj + "\' for column " + colName;
                        throw new DBException(errMsg);
                    }
                    return valueObj;

case col.getPrecision() == 0 should be cared for some databases. So
"col.getPrecision() != 0 &&" needs to be added.

                    if (col.getPrecision() != 0 && valueObj.toString().length() > col.getPrecision()) {
Comment 1 Jiri Rechtacek 2010-04-06 14:58:58 UTC
The hint for patch looks good but I need some information how to reproducible the problem. I tried reproduce it on my PostreSQL database and IDE didn't allow me to make a column which returns 0 from getPrecision(). I guess UI in DB support avoid creating such columns. Please, give my steps how to reproduce. Thanks
Comment 2 Masaki Katakai 2010-04-06 15:40:22 UTC
Hi Jiri, Thank you very much for evaluation!

I'm sorry I don't know how to create such columns - probably it was created outside ide. getPrecision() for 'varchar' and 'text' may return 0. It happens only in PostgreSQL.

http://archives.postgresql.org/pgsql-jdbc/2010-01/msg00077.php
Comment 3 Jiri Rechtacek 2010-04-14 10:22:52 UTC
Already fixed in NB6.8
Changeset: http://hg.netbeans.org/main-golden/rev/508c41bf7ef8
User: Jiri Rechtacek <jrechtacek@netbeans.org>