Skip site navigation (1) Skip section navigation (2)

[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 (view raw or flat)
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

pgadmin-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group