Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d5Wur-0007fQ-Ub for pgadmin-hackers@arkaria.postgresql.org; Tue, 02 May 2017 12:28:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d5Wur-0005bR-H6 for pgadmin-hackers@arkaria.postgresql.org; Tue, 02 May 2017 12:28:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d5Wuq-0005YR-7F for pgadmin-hackers@postgresql.org; Tue, 02 May 2017 12:28:28 +0000 Received: from mail-wr0-x22c.google.com ([2a00:1450:400c:c0c::22c]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d5Wul-0004Y6-8Z for pgadmin-hackers@postgresql.org; Tue, 02 May 2017 12:28:27 +0000 Received: by mail-wr0-x22c.google.com with SMTP id l50so78710076wrc.3 for ; Tue, 02 May 2017 05:28:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=w0Cqn42igc+nLZBNgzeD243pQif6mo33IJg+Ltf0DDo=; b=xBYSpErvMudc1E7p+yXpWwhwu7lir2dB6N9Bzz4OZGbYJjcmNnfRi61dUR0xcXPEb+ KqTjn6wPlRoju4O/BJuL3zkpIA/fZg0Yw2Ft4BDK/2btQXTpGM1g/WPwMJH1dVy7Zwqx s4ugO0x0Tb38LxLrj6jvDF4IT1T6TNO0Vk5CkTVkj5hkKp10VlCFtn+kDHXYIPt1LE1Z 5wAMvP4zfyFhyVciPqy/uypPGkEcY0pKHC4RaQvHfIxJnxIO0SnfOGdGYCSoUBYygQRI Cf/BpDd173HCcWoX4HvFncEE8yWeitXQxZ28MkhvnaGz1CLlZYfZC5RrBRCrnD5UamYG 4wDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=w0Cqn42igc+nLZBNgzeD243pQif6mo33IJg+Ltf0DDo=; b=KWKzBPqMa70UM9W03G5EFUtIFdfvRMIF/CDFgWvG2EdoTteSgOZ3byP1BsvoyhAQJX if6Gv4K39SfC3pUY5PACxO4NqDgGqCps+U4/Nq1zEHyuDJrMK2fUlv/ULrxOqEEZojZY YQdzV7XxEyMP9S8HmEmEC9MBS3olD+3+mqbCDulvejeemamOxXZeuWOcE2HTuLt7sdWM vx64Ig3+aFtwZbFUMMtDRRDOJRPJyZ91l3TuPOscgfgrJYy2GTNQd37hsqQa7KwLlBZl P2cqbvoLr6AwWvOiVeu4Qsz2gDJ/uV8yo4f/PL0bfombHwoQF7R4Gp1VbHKyXjJQHvR2 yWGA== X-Gm-Message-State: AN3rC/7B5SpRazAxpTmP3DLpSLDgyJ3pcKOvrL1pbcwpWplj1Cpw81tG ma9HjIYTGWWHvg4Qp5OIoBuGZOlsiZI0 X-Received: by 10.223.136.235 with SMTP id g40mr19955681wrg.107.1493728101985; Tue, 02 May 2017 05:28:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.19.134 with HTTP; Tue, 2 May 2017 05:27:51 -0700 (PDT) In-Reply-To: References: From: Surinder Kumar Date: Tue, 2 May 2017 17:57:51 +0530 Message-ID: Subject: Re: [pgAdmin4][Patch][RM2257]: Query tool - Insert row doesn't use default values To: Dave Page Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary=001a11498cd4e90f4a054e89ac56 X-Pg-Spam-Score: -1.6 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgadmin-hackers Precedence: bulk Sender: pgadmin-hackers-owner@postgresql.org --001a11498cd4e90f4a054e89ac56 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Dave, On Tue, May 2, 2017 at 5:21 PM, Dave Page wrote: > Hi, > > This is looking much better now :-). Couple of thoughts and a bug: > > - Only the TextFormatter seems to handle both [null] and [default] values= . > Shouldn't all formatters do so (including Json and Checkmark)? > =E2=80=8BYes, I will apply the same changes for other formatters too.=E2=80= =8B > For example, "serial" columns currently get displayed as [null] when left > blank, but I would expect to see [default]. > > - I would suggest we put [null] and [default] in a lighter colour - > #999999. > > - With the feature test patch added, I seem to be consistently getting th= e > following failure (immediately after your new tests run): > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ERROR: runTest (pgadmin.feature_tests.xss_checks_panels_and_query_tool_ > test.CheckForXssFeatureTest) > Test XSS check for panels and query tool > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_featu= re_test.py", > line 42, in setUp > self._screenshot() > File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_featu= re_test.py", > line 92, in _screenshot > python_version)) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 802, in > get_screenshot_as_file > png =3D self.get_screenshot_as_png() > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 821, in > get_screenshot_as_png > return base64.b64decode(self.get_screenshot_as_base64().encode( > 'ascii')) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 831, in > get_screenshot_as_base64 > return self.execute(Command.SCREENSHOT)['value'] > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 238, in execute > self.error_handler.check_response(response) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/errorhandler.py", line 193, in > check_response > raise exception_class(message, screen, stacktrace) > UnexpectedAlertPresentException: Alert Text: None > Message: unexpected alert open: {Alert text : Are you sure you wish to > close the pgAdmin 4 browser?} > (Session info: chrome=3D58.0.3029.81) > (Driver info: chromedriver=3D2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405= b483f5ae83b),platform=3DMac > OS X 10.12.3 x86_64) > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > ERROR: runTest (pgadmin.feature_tests.xss_checks_pgadmin_debugger_test. > CheckDebuggerForXssFeatureTest) > Test table DDL generation > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_featu= re_test.py", > line 42, in setUp > self._screenshot() > File "/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_featu= re_test.py", > line 92, in _screenshot > python_version)) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 802, in > get_screenshot_as_file > png =3D self.get_screenshot_as_png() > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 821, in > get_screenshot_as_png > return base64.b64decode(self.get_screenshot_as_base64().encode( > 'ascii')) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 831, in > get_screenshot_as_base64 > return self.execute(Command.SCREENSHOT)['value'] > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/webdriver.py", line 238, in execute > self.error_handler.check_response(response) > File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site- > packages/selenium/webdriver/remote/errorhandler.py", line 193, in > check_response > raise exception_class(message, screen, stacktrace) > UnexpectedAlertPresentException: Alert Text: None > Message: unexpected alert open: {Alert text : Are you sure you wish to > close the pgAdmin 4 browser?} > (Session info: chrome=3D58.0.3029.81) > (Driver info: chromedriver=3D2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405= b483f5ae83b),platform=3DMac > OS X 10.12.3 x86_64) > =E2=80=8BSure. I will fix this.=E2=80=8B > > Thanks! > > > On Fri, Apr 28, 2017 at 10:19 AM, Surinder Kumar < > surinder.kumar@enterprisedb.com> wrote: > >> Hi Dave, >> >> Please find updated patch for RM case and a separate patch for Feature >> tests. >> >> *Python:* >> >> - Added [default] label for cells with default values while inserting a >> new row. >> >> - Introduced a FieldValidator function for cells that don't allow null >> values. If user tries to insert null value, field with be highlighted wi= th >> red borders around. >> >> =E2=80=8B- >> If a cell contains blank string('') and when we set it to null, the >> change into the cell is not detected. It was because the comparison >> for (defaultValue =3D=3D null) return true if defaultValue is undefined. >> Hence _.isNull(value) is used to fix this. >> >> *Feature Test cases:* >> >> - Introduced a new method create_table_with_query(server, db_name, >> query) in test_utils.py which executes the given query on connected >> server. >> >> - Added a new file test_data.json that has test data for test cases. >> >> >> On Fri, Apr 7, 2017 at 2:21 PM, Dave Page wrote: >> >>> Hi >>> >>> On Sat, Apr 1, 2017 at 12:45 PM, Surinder Kumar >>> wrote: >>> > Hi >>> > >>> > Issues fixed: >>> > >>> > 1. If a column is defined with a default modifier, there is now way t= o >>> > insert the row with those defaults. >>> > The column will be left blank and it will take default value >>> automatically. >>> > >>> > 2. If a column has a not-null constraint then an error is returned an= d >>> the >>> > row is not inserted. >>> > The column will be left blank >>> > >>> > The default values for new added rows will be displayed on >>> refresh/execute. >>> > >>> > Please find attached patch and review. >>> >>> This largely works as expected, but there is some weirdness. I have a >>> test table that looks like this: >>> >>> CREATE TABLE public.defaults >>> ( >>> id bigint NOT NULL DEFAULT nextval('defaults_id_seq'::regclass), >>> data_default_nulls text COLLATE pg_catalog."default" DEFAULT >>> 'abc123'::text, >>> data_default_no_nulls text COLLATE pg_catalog."default" NOT NULL >>> DEFAULT 'def456'::text, >>> data_nulls text COLLATE pg_catalog."default", >>> data_no_nulls text COLLATE pg_catalog."default" NOT NULL, >>> CONSTRAINT defaults_pkey PRIMARY KEY (id) >>> ) >>> >>> Remember that the expected behaviour is: >>> >>> - Set a value to empty to update the column to null. >>> - Set a value to '' to update the column to an empty string >>> - Set a value to anything else to update the column to that value >>> >>> 1) In a row with values in each column, if I try to set the value of >>> data_default_nulls to null, the query executed is: >>> >>> UPDATE public.defaults SET >>> data_default_nulls =3D '' WHERE >>> id =3D '2'; >>> >>> 2) If I do the same in the data_nulls column, the value is immediately >>> shown as [null] and the query executed is: >>> >>> UPDATE public.defaults SET >>> data_nulls =3D NULL WHERE >>> id =3D '2'; >>> >>> 3) If I then edit the value in data_default_nulls, it shows the >>> current value as ''. Removing the quotes (to set it to null) doesn't >>> get detected as a change. >>> >> =E2=80=8B=E2=80=8BTaken care. >> >>> >>> 4) When I manually executed "update defaults set data_default_nulls =3D >>> null where id =3D 2" in a query tool window, I got: >>> >>> 2017-04-07 09:43:02,987: INFO werkzeug: 127.0.0.1 - - [07/Apr/2017 >>> 09:43:02] "GET /sqleditor/columns/8745675 HTTP/1.1" 500 - >>> Traceback (most recent call last): >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 2000, in __call__ >>> return self.wsgi_app(environ, start_response) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1991, in wsgi_app >>> response =3D self.make_response(self.handle_exception(e)) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1567, in handle_exception >>> reraise(exc_type, exc_value, tb) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1988, in wsgi_app >>> response =3D self.full_dispatch_request() >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1641, in full_dispatch_request >>> rv =3D self.handle_user_exception(e) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1544, in handle_user_exception >>> reraise(exc_type, exc_value, tb) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1639, in full_dispatch_request >>> rv =3D self.dispatch_request() >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask/app.py", >>> line 1625, in dispatch_request >>> return self.view_functions[rule.endpoint](**req.view_args) >>> File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packa >>> ges/flask_login.py", >>> line 792, in decorated_view >>> return func(*args, **kwargs) >>> File "/Users/dpage/git/pgadmin4/web/pgadmin/tools/sqleditor/__ini >>> t__.py", >>> line 452, in get_columns >>> tid=3Dcommand_obj.obj_id) >>> AttributeError: 'QueryToolCommand' object has no attribute 'obj_id' >>> >> =E2=80=8BFixed.=E2=80=8B >> >>> >>> 5) When I run the query again in pgAdmin III, then refresh the data in >>> pgAdmin 4, the data_default_nulls column is displayed without the >>> [null] marker (despite having a null value, which I confirmed in >>> pgAdmin 3). >>> >> =E2=80=8BFixed.=E2=80=8B >> >>> >>> I'm sure there are other combinations of issues here. Please fix and >>> thoroughly re-test to ensure behaviour is consistent - and to avoid >>> future issues, please add some appropriate feature tests to check >>> nulls, defaults and empty strings are properly handled in view, insert >>> and updates. Murtuza recently wrote some feature tests for the query >>> tool - you should be able to use those as a starting point. >>> >> =E2=80=8BAdded feature tests=E2=80=8B >> >>> >>> Thanks. >>> >>> -- >>> Dave Page >>> Blog: http://pgsnake.blogspot.com >>> Twitter: @pgsnake >>> >>> EnterpriseDB UK: http://www.enterprisedb.com >>> The Enterprise PostgreSQL Company >>> >> >> > > > -- > Dave Page > Blog: http://pgsnake.blogspot.com > Twitter: @pgsnake > > EnterpriseDB UK: http://www.enterprisedb.com > The Enterprise PostgreSQL Company > --001a11498cd4e90f4a054e89ac56 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi = Dave,

On Tue= , May 2, 2017 at 5:21 PM, Dave Page <dpage@pgadmin.org> wrot= e:
Hi,

This is looking much better now :-). Couple of thoughts and a bug:
<= div>
- Only the TextFormatter seems to handle both [null] and= [default] values. Shouldn't all formatters do so (including Json and C= heckmark)?
=E2=80=8BYes, I will apply the same changes for other format= ters too.=E2=80=8B
For example, "serial" columns currently get displayed as [null= ] when left blank, but I would expect to see [default].=C2=A0
- I would suggest we put [null] and [default] in a lighter colo= ur - #999999.

- With the feature test patch added,= I seem to be consistently getting the following failure (immediately after= your new tests run):

=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
ERROR: runTest= (pgadmin.feature_tests.xss_checks_panels_and_query_tool_test.Che= ckForXssFeatureTest)
Test XSS check for panels and query tool
----------------------------------------------------------------------
Traceback (most recent call last):<= /div>
=C2=A0 File "/Users/dpage/git/pgadmin4/web/regre= ssion/feature_utils/base_feature_test.py", line 42, in setUp
=C2=A0 =C2=A0 self._screenshot()
=C2=A0 File "/Users/d= page/git/pgadmin4/web/regression/feature_utils/base_feature_test.= py", line 92, in _screenshot
=C2=A0 =C2=A0 python_version))<= /div>
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/pyt= hon2.7/site-packages/selenium/webdriver/remote/webdriver.py"= , line 802, in get_screenshot_as_file
=C2=A0 =C2=A0 png =3D self.= get_screenshot_as_png()
=C2=A0 File "/Users/dpage/.virtualen= vs/pgadmin4/lib/python2.7/site-packages/selenium/webdriver/r= emote/webdriver.py", line 821, in get_screenshot_as_png
=C2= =A0 =C2=A0 return base64.b64decode(self.get_screenshot_as_base64().enc= ode('ascii'))
=C2=A0 File "/Users/dpage/.virtua= lenvs/pgadmin4/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 831, in get_screenshot_as_base64
=C2=A0 =C2=A0 return self.execute(Command.SCREENSHOT)['value'= ;]
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/= python2.7/site-packages/selenium/webdriver/remote/webdriver.py&qu= ot;, line 238, in execute
=C2=A0 =C2=A0 self.error_handler.check_= response(response)
=C2=A0 File "/Users/dpage/.virtualen= vs/pgadmin4/lib/python2.7/site-packages/selenium/webdriver/r= emote/errorhandler.py", line 193, in check_response
=C2=A0 = =C2=A0 raise exception_class(message, screen, stacktrace)
Unexpec= tedAlertPresentException: Alert Text: None
Message: unexpect= ed alert open: {Alert text : Are you sure you wish to close the pgAdmin 4 b= rowser?}
=C2=A0 (Session info: chrome=3D58.0.3029.81)
= =C2=A0 (Driver info: chromedriver=3D2.29.461585 (0be2cd95f834e9ee7c46b= cc7cf405b483f5ae83b),platform=3DMac OS X 10.12.3 x86_64)

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D
ERROR: runTest (pgadmin.feature_tests.xs= s_checks_pgadmin_debugger_test.CheckDebuggerForXssFeatureTest)
Test table DDL generation
--------------------------= --------------------------------------------
Traceback (most recent call last):
=C2=A0 File &quo= t;/Users/dpage/git/pgadmin4/web/regression/feature_utils/base_fea= ture_test.py", line 42, in setUp
=C2=A0 =C2=A0 self._screens= hot()
=C2=A0 File "/Users/dpage/git/pgadmin4/web/regres= sion/feature_utils/base_feature_test.py", line 92, in _screenshot=
=C2=A0 =C2=A0 python_version))
=C2=A0 File "/User= s/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/seleniu= m/webdriver/remote/webdriver.py", line 802, in get_screenshot_as_= file
=C2=A0 =C2=A0 png =3D self.get_screenshot_as_png()
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/si= te-packages/selenium/webdriver/remote/webdriver.py", line 82= 1, in get_screenshot_as_png
=C2=A0 =C2=A0 return base64.b64decode= (self.get_screenshot_as_base64().encode('ascii'))
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/= site-packages/selenium/webdriver/remote/webdriver.py", line = 831, in get_screenshot_as_base64
=C2=A0 =C2=A0 return self.execut= e(Command.SCREENSHOT)['value']
=C2=A0 File "/Us= ers/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/selen= ium/webdriver/remote/webdriver.py", line 238, in execute
=C2=A0 =C2=A0 self.error_handler.check_response(response)
= =C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/selenium/webdriver/remote/errorhandler.py", line = 193, in check_response
=C2=A0 =C2=A0 raise exception_class(messag= e, screen, stacktrace)
UnexpectedAlertPresentException: Aler= t Text: None
Message: unexpected alert open: {Alert text : Are yo= u sure you wish to close the pgAdmin 4 browser?}
=C2=A0 (Session = info: chrome=3D58.0.3029.81)
=C2=A0 (Driver info: chromedriver=3D= 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform= =3DMac OS X 10.12.3 x86_64)
=E2=80=8BSure. I will fix this.=E2=80= =8B

Thanks!


On Fri, Apr 28, 2017 at 10:19 AM, Surin= der Kumar <surinder.kumar@enterprisedb.com> wrote:
Hi Dave,

Please find updated patch fo= r RM case and a separate patch for Feature tests.

Python:

- Adde= d=C2=A0[default] label for cells with defaul= t values while inserting a new row.

- Introduced a FieldValidator = function for cells that don't allow null values. If user tries to inser= t null value, field with be highlighted with red =C2=A0 =C2=A0borders aroun= d.

=E2=80=8B-=C2=A0
If a cell contains blank string(&= #39;') and when we set it to null, the change into the cell is not dete= cted. It was because the comparison
for (defaultValue =3D=3D null) retur= n true if defaultValue is undefined. Hence _.isNull(value) is used to fix t= his.

Feature Test cases:

=C2=A0- Introduced a new method=C2=A0create_table_with_qu= ery(server, db_name, query)=C2=A0 in test_utils.py which execut= es the given query on connected server.

=C2=A0- Ad= ded a new file test_data.json that has test data for test cases.
=

On Fri, Apr 7, 2017 at 2:21 PM, = Dave Page <dpage@pgadmin.org> wrote:
Hi

On Sat, Apr 1, 2017 at 12:45 PM, Surinder Kumar
<su= rinder.kumar@enterprisedb.com> wrote:
> Hi
>
> Issues fixed:
>
> 1. If a column is defined with a default modifier, there is now way to=
> insert the row with those defaults.
> The column will be left blank and it will take default value automatic= ally.
>
> 2. If a column has a not-null constraint then an error is returned and= the
> row is not inserted.
> The column will be left blank
>
> The default values for new added rows will be displayed on refresh/exe= cute.
>
> Please find attached patch and review.

This largely works as expected, but there is some weirdness. I have = a
test table that looks like this:

CREATE TABLE public.defaults
(
=C2=A0 =C2=A0 id bigint NOT NULL DEFAULT nextval('defaults_id_seq':= :regclass),
=C2=A0 =C2=A0 data_default_nulls text COLLATE pg_catalog."default"= ; DEFAULT 'abc123'::text,
=C2=A0 =C2=A0 data_default_no_nulls text COLLATE pg_catalog."default&q= uot; NOT NULL
DEFAULT 'def456'::text,
=C2=A0 =C2=A0 data_nulls text COLLATE pg_catalog."default",
=C2=A0 =C2=A0 data_no_nulls text COLLATE pg_catalog."default" NOT= NULL,
=C2=A0 =C2=A0 CONSTRAINT defaults_pkey PRIMARY KEY (id)
)

Remember that the expected behaviour is:

- Set a value to empty to update the column to null.
- Set a value to '' to update the column to an empty string
- Set a value to anything else to update the column to that value

1) In a row with values in each column, if I try to set the value of
data_default_nulls to null, the query executed is:

UPDATE public.defaults SET
data_default_nulls =3D '' WHERE
id =3D '2';

2) If I do the same in the data_nulls column, the value is immediately
shown as [null] and the query executed is:

UPDATE public.defaults SET
data_nulls =3D NULL WHERE
id =3D '2';

3) If I then edit the value in data_default_nulls, it shows the
current value as ''. Removing the quotes (to set it to null) doesn&= #39;t
get detected as a change.
=E2=80=8B=E2=80=8BTaken care.=C2=A0

4) When I manually executed "update defaults set data_default_nulls = =3D
null where id =3D 2" in a query tool window, I got:

2017-04-07 09:43:02,987: INFO werkzeug: 127.0.0.1 - - [07/Apr/2017
09:43:02] "GET /sqleditor/columns/8745675 HTTP/1.1" 500 -
Traceback (most recent call last):
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 2000, in __call__
=C2=A0 =C2=A0 return self.wsgi_app(environ, start_response)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1991, in wsgi_app
=C2=A0 =C2=A0 response =3D self.make_response(self.handle_exception(e)= )
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1567, in handle_exception
=C2=A0 =C2=A0 reraise(exc_type, exc_value, tb)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1988, in wsgi_app
=C2=A0 =C2=A0 response =3D self.full_dispatch_request()
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1641, in full_dispatch_request
=C2=A0 =C2=A0 rv =3D self.handle_user_exception(e)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1544, in handle_user_exception
=C2=A0 =C2=A0 reraise(exc_type, exc_value, tb)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1639, in full_dispatch_request
=C2=A0 =C2=A0 rv =3D self.dispatch_request()
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask/app.py",
line 1625, in dispatch_request
=C2=A0 =C2=A0 return self.view_functions[rule.endpoint](**req.view_arg= s)
=C2=A0 File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/sit= e-packages/flask_login.py",
line 792, in decorated_view
=C2=A0 =C2=A0 return func(*args, **kwargs)
=C2=A0 File "/Users/dpage/git/pgadmin4/web/pgadmin/tools/sqledito= r/__init__.py",
line 452, in get_columns
=C2=A0 =C2=A0 tid=3Dcommand_obj.obj_id)
AttributeError: 'QueryToolCommand' object has no attribute 'obj= _id'
=E2=80= =8BFixed.=E2=80=8B

5) When I run the query again in pgAdmin III, then refresh the data in
pgAdmin 4, the data_default_nulls column is displayed without the
[null] marker (despite having a null value, which I confirmed in
pgAdmin 3).
=E2=80=8B= Fixed.=E2=80=8B

I'm sure there are other combinations of issues here. Please fix and thoroughly re-test to ensure behaviour is consistent - and to avoid
future issues, please add some appropriate feature tests to check
nulls, defaults and empty strings are properly handled in view, insert
and updates. Murtuza recently wrote some feature tests for the query
tool - you should be able to use those as a starting point.
=E2=80=8BAdded feature tests=E2=80= =8B

Thanks.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company




--
Dave Page
Blog: http://pgsnake.blogspot.com=
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterpr= ise PostgreSQL Company

--001a11498cd4e90f4a054e89ac56--