[Patch] Multiline paste bug in EditGrid

From: Robins <robins(at)pobox(dot)com>
To: pgadmin-hackers(at)postgresql(dot)org
Subject: [Patch] Multiline paste bug in EditGrid
Date: 2011-09-08 01:04:26
Message-ID: CAEP4nAwutDdsM2No4EF2Yfy=ukQH7SBnhuuTfz8DuwLJD5Vi5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Hi,

This is a small patch for a small bug I found while working in EditGrid.
I've outlined the bug below and given the patch alongside.

I intend to work on a few more minor bugs / small enhancements, that I've
noted down over time. Do let me know in case you believe that these patches
come in another way / presented differently etc..

---
*Robins Tharakan*
*
*
Issue: When we paste the following onto the first cell of the last row (the
empty row) in EditGrid, the last column is incorrectly evaluated. The value
accepted goes beyond the '\n' and is an odd mix of values with a '\n'
sandwiched in between. It generally is the last column of the first row as
well as the first value of the next row, with a '\n' sandwiched in between.
(If the first cell of the next row is quoted, the beginning quote is
included in this value as well). I believe that until we have a system in
place to accept multi-line paste, ideally we should omit the remaining lines
for now.

I've provided a few sample test cases below for better understanding.

Table:
CREATE TABLE tempdel
(
project character varying(100) NOT NULL,
st date,
stop date,
CONSTRAINT pk PRIMARY KEY (project )
)
WITH (
OIDS=FALSE
);

Patch:
--- a/pgadmin/frm/frmEditGrid.cpp
+++ b/pgadmin/frm/frmEditGrid.cpp
@@ -3042,7 +3042,7 @@ bool sqlTable::Paste()
}

if (inQuotes && text[pos] == quoteChar &&
- text[pos + 1] == colSep)
+ (text[pos + 1] == colSep || text[pos + 1] == '\n'))
{
data.Add(text.Mid(start, pos - start));
start = (pos += 2);

===========
Test Case 1:
XML1a;"2010-12-24";"2011-02-24"
XML1b;"2010-12-24";"2011-02-24"

Last Cell Contents:
2011-02-24"
XML1b;"2010-12-24

===========
Test Case 2:
XML2a;2010-12-24;"2011-02-24"
XML2b;2010-12-24;"2011-02-24"

Last Cell Contents:
2011-02-24"
XML2b;2010-12-24;"2011-02-24"

===========
Test Case 5:
XML5a;"2010-12-24";"2011-02-24"

XML5b;"2010-12-24";"2011-02-24"

Last Cell Contents:
2011-02-24"

XML5b;"2010-12-24

===========
Test Case 6:
XML6a;"2010-12-24";"2011-02-24"
;"2010-12-24";"2011-02-24"

Last Cell Contents:
2011-02-24"
;"2010-12-24

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dave Page 2011-09-08 16:07:04 pgAdmin III commit: Fix pasting in the Edit Grid to avoid tacking garba
Previous Message Guillaume Lelarge 2011-09-06 18:40:13 Re: Polish translation of pgadmin3.po