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 149635 - Default value isn't inserted
Summary: Default value isn't inserted
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Shansi 11
URL:
Keywords:
Depends on: 154926
Blocks:
  Show dependency tree
 
Reported: 2008-10-09 14:24 UTC by Roman Mostyka
Modified: 2009-04-08 14:07 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 Roman Mostyka 2008-10-09 14:24:28 UTC
1. Connect to some DB and expand it's node.
2. Rightclick "Tables" node and choose "Create Table...".
3. Set table name, column name, set VARCHAR for the column type, set "test" as default value and click "OK".
4. Rightclick created table and choose "View Data...".
5. Press "Insert Record" button and click "OK" without specifying any value.

Result: Empty record is inserted. There is no any default value inserted.
Comment 1 John Baker 2008-10-10 06:31:41 UTC
Seems rather nitpicky.  The OK button could be disabled until values are specified.

I think this is a P4
Comment 2 _ ahimanikya 2008-10-10 07:10:07 UTC
Default value will be used only when you skip a column or try to set NULL. 
Comment 3 Roman Mostyka 2008-10-13 09:40:25 UTC
John, I don't agree that it is nitpick. When customer enters default value it is expected that this value will work as
expected (as usual), but it doesn't. Why we need this value if it doesn't work? Why we "tell" customer that this can be
used if it can't?
Ahi, what do you mean "when you skip a column". If you mean execution of a SQL statement, then this is OK. But why we
don't have in this case the same functionality in "Insert Record" dialog. If it can't be used for entering data, only in
some simple cases, then why we need this dialog? How is it hard to implement?
As you can see in my steps to reproduce, I skipped this column in the dialog, but default value wasn't inserted.
Correct me please if I'm wrong somewhere or misunderstood you.
Comment 4 _ ahimanikya 2008-10-13 09:56:51 UTC
There is some design issues here. By default we fill these fields with empty string and when user does not fill anything
we pass empty string to database server that will not hint the server to use default value. 

However we do allow user to set NULL with CTRL+0, in which case default value will be used. We could tweak the screen
design and may have some CTRL key combination or check box to use the DEFAULT value. 

I would think this is an enhancement request, which we could cater in next release.
Comment 5 Roman Mostyka 2008-10-13 10:14:19 UTC
How hard is it to fix? Actually it ca be risky to fix it now, but it isn't ENHANCEMENT, this is really DEFECT since IDE
don't have usual functionality.
If it is risky I agree that we can work on this in next release (or better to have fix for this in nearest patch).
And I guess suggested implementation is OK, but can we check if column has default value and insert it without any
action if nothing is entered for this column? I think it should be better approach.
Comment 6 _ ahimanikya 2008-10-13 10:36:19 UTC
I don't agree with your logic, however its not a good idea to make any changes to the screen now. We will deal with this
in next release, can we get feedback from HFI? 

Like I said, when you are not entering any value it will try to insert empty string. If you want to either insert NULL
or DEFAULT value please use CTRL+0.

We are not checking whether the column has default value or not, and we should be checking it either. 
Comment 7 Roman Mostyka 2008-10-13 10:47:10 UTC
OK, I agree that we shouldn't change screen now, we can do this in nearest patch, as I said.
Comment 8 _ ahimanikya 2008-10-13 12:10:43 UTC
But again as I said before the existing way to hint the database to use default value is to set NULL for a given field
by using CTRL+0

Unless we have clear solution with HFI feedback, I would not like to disturb the current screen. 

The best thing that I can think of - provide yet another key combination such as CTRL+1 to set DEFAULT (but IMO this
will be redundant, people with basic sql knowledge would understand that fact that when he/she set NULL, the DEFAULT
value be used if defined on INSERT)

The other option could be just update the text on the header. that should look like this "Press CTRL+0 to toggle setting
NULL value for a given column. Please set the field value to NULL to use the DEFAULT if defined on INSERT"
Comment 9 Roman Mostyka 2008-10-13 14:44:43 UTC
I think first way (another key combination) is better. What if customer really want to have NULL in a field, but no
default value?
Comment 10 David Vancouvering 2008-10-29 00:52:15 UTC
I believe that NULL should be the default setting for columns that aren't given values, rather than an empty string.  I
wouldn't expect the db tool to automatically set a field to an empty string.  What about columns of non-string types? 
What do you do there?  You're implicitly creating default values for fields when the user hasn't asked you to do that.

IMHO when you create a new row in DataView, you should pre-fill all the fields with <NULL> and let the user explicitly
set these to something.  Setting them to an empty string doesn't make sense.

David
Comment 11 Roman Mostyka 2008-11-19 14:20:20 UTC
sivashankari, can You take a look at this issue? This issue is P3, but it looks like presented functionality doesn't
work well and therefore this issue is going to be included into NetBeans 6.5 Patch 1.
Please fix it till 27 November (this is code freeze date for Patch 1) or update this issue with justification why the
fix isn't possible till this date.
Thanks.
Comment 12 pgebauer 2008-11-24 09:31:11 UTC
The issue didn't pass the nomination process by nomination cut-off date. It has been marked as 65fixes2-candidate.
Comment 13 _ ahimanikya 2008-12-07 17:32:09 UTC
http://hg.netbeans.org/main/rev/706089393902
Comment 14 Roman Mostyka 2008-12-09 09:58:48 UTC
Verified with build 081208.
Comment 15 Quality Engineering 2008-12-09 18:35:10 UTC
Integrated into 'main-golden', will be available in build *200812091520* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/706089393902
User: ahimanikya@netbeans.org
Log: Issue #149635 Default value isn't inserted
Comment 16 pgebauer 2008-12-19 16:37:33 UTC
I'm still able to reproduce this issue after the transfer of the changeset 706089393902 into the release65_fixes branch. Two hunks (see below) have been 
rejected however they don't seem to be related to this issue. The issue probably was fixed in synergy with changes related to other issues. Since this is the 
P3 issue, I propose to remove it from any proactive patch.

--- DataViewTableUI.java
+++ DataViewTableUI.java
@@ -647,9 +646,9 @@ class DataViewTableUI extends ExtendedJT
 
         private void setTableCellToolTip(Component c, Object value) {
             if (c instanceof JComponent) {
-                String tooltip = "<html><table border=0 cellspacing=0 cellpadding=0 width=40><tr><td>";
-                tooltip += DataViewUtils.escapeHTML(value.toString()).replaceAll("\\n", "<br>").replaceAll(" ", "&nbsp;");
-                tooltip += "</td></tr></table></html>";
+                String tooltip = "<html><table border=0 cellspacing=0 cellpadding=0 width=40><tr><td>"; // NOI18N
+                tooltip += DataViewUtils.escapeHTML(value.toString()).replaceAll("\\n", "<br>").replaceAll(" ", "&nbsp;"); // NOI18N
+                tooltip += "</td></tr></table></html>"; // NOI18N
                 ((JComponent) c).setToolTipText(tooltip);
             }
         }

--- SQLStatementGenerator.java
+++ SQLStatementGenerator.java
@@ -228,7 +234,7 @@ class SQLStatementGenerator {
     }
 
     static String getCountAsSubQuery(String queryString) {
-        return "SELECT COUNT(*) FROM (" + queryString + ") C"; // NOI18N
+        return "SELECT COUNT(*) FROM (" + queryString + ") C2668"; // NOI18N
     }
 
     private boolean addSeparator(boolean and, StringBuilder result, StringBuilder raw, String sep) {

Comment 17 Roman Mostyka 2008-12-22 11:24:57 UTC
Petr, the fix for this issue depends on the fix of the issue #154926. Issue #154926 is also nominated for Patch 2, So
please port first the fix for the issue #154926.
This issue doesn't break work flow, but it make it not so convenient and actually without this fix functionality looks
like unfinished.
Comment 18 pgebauer 2009-01-05 13:43:56 UTC
Roman, the fix for the issue #154926 was already ported when I tried to port the fix for this issue. So my conclusion is still valid. 
Comment 19 Roman Mostyka 2009-01-10 21:19:28 UTC
Thanks Petr for investigation.
Ahi, can you take a look on this issue. Probably it was fixed not for all cases.
Comment 20 pgebauer 2009-01-15 10:14:35 UTC
No solution for the release65_fixes branch was provided by 65patch2 code freeze. The issues has been moved to 65patch3.
Comment 21 pgebauer 2009-04-08 14:07:28 UTC
The status whiteboard "65fixes4-candidate" has been removed.
At this time our proactive patches for the NetBeans 6.5.x IDE have concluded.

If you own a Sun service plan contract for NetBeans, you may wish to contact
Sun Service http://www.sun.com/contact/support.jsp to request a fix via the
product defect escalation process.

For more information on purchasing a Sun service plan contract for NetBeans,
refer to the service plan item "Sun Software Service Plans (S3P) for Developers"
in the Sun Service table found on our NetBeans Support Resources
page http://www.netbeans.org/kb/support.html