Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-06-15 Thread Harshal Dhumal
Hi

On Fri, Jun 16, 2017 at 2:07 AM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Thu, Jun 15, 2017 at 9:30 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > Please find attached updated patch.
> >
> > On Thu, Jun 15, 2017 at 3:58 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Hi
> >>
> >> On Wed, Jun 14, 2017 at 11:36 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >>>
> >>> Hi Dave,
> >>>
> >>> Please find rebased patch for RM2137.
> >>
> >>
> >> Looking very good. The only issues I see are:
> >>
> >> - The row headers should auto-size such that they can display the row
> >> numbers if the last row was displayed. E.g. if there are 12345 rows in
> >> total, then the row header should be sized to display 5 digits.
> >>
> > Fixed.
> >
> >
> >>
> >> - The tests are comprehensive, which is awesome. However, every time I
> ran
> >> them, at least one of the feature tests failed. Unfortunately, it was a
> >> different one each time. In the last two runs, I got:
> >>
> >>  ==
> >> ERROR: runTest
> >> (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
> >> Query tool feature test
> >> --
> >> Traceback (most recent call last):
> >>   File
> >> "/Users/dpage/git/pgadmin4/web/regression/feature_utils/
> base_feature_test.py",
> >> line 40, in setUp
> >> self.before()
> >>   File
> >> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/
> query_tool_tests.py",
> >> line 40, in before
> >> self._connects_to_server()
> >>   File
> >> "/Users/dpage/git/pgadmin4/web/pgadmin/feature_tests/
> query_tool_tests.py",
> >> line 144, in _connects_to_server
> >> self.page.driver.find_element_by_link_text("Create"))\
> >>   File
> >> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/selenium/webdriver/remote/webdriver.py",
> >> line 319, in find_element_by_link_text
> >> return self.find_element(by=By.LINK_TEXT, value=link_text)
> >>   File
> >> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/selenium/webdriver/remote/webdriver.py",
> >> line 756, in find_element
> >> 'value': value})['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)
> >> NoSuchElementException: Message: no such element: Unable to locate
> >> element: {"method":"link text","selector":"Create"}
> >>   (Session info: chrome=58.0.3029.110)
> >>   (Driver info: chromedriver=2.29.461585
> >> (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.3
> x86_64)
> >>
> > I checked code from _connects_to_server function which is common in all
> > features test cases. I didn't find anything wrong with this. If there is
> a
> > bug in this function then all feature test must fail.
> > Let me know if you are getting failure consistently in
> _connects_to_server
> > function.
>
> I wondered if that one is a race condition. Do we need a short delay
> before clicking the Object menu? I have seen this occasionally before.
>

OK. In that case let's try putting 1-2 second delay and observer behaviour.
I'll send separate patch for this tomorrow as this is not related to on
demand query result feature or its test cases.


>
> >>
> >>
> >> ==
> >> ERROR: runTest
> >> (pgadmin.feature_tests.query_tool_tests.QueryToolFeatureTest)
> >> Query tool feature test
> >> --
> >> Traceback (most recent call last):
> >>   File
> >> "/Users/dpage/g

Re: [pgadmin-hackers] pgAdmin 4 commit: Use a more sensible name for Query Tool tabs. Fixes #

2017-06-14 Thread Harshal Dhumal
Surinder,

I guess this broke the script options (Create, Delete, Select, Insert,
Update)


VM4124 datagrid.js:440 Uncaught TypeError: self.get_panel_title is not a
function at Object.success (VM4124 datagrid.js:440) at fire (
jquery-1.11.2.js:3143) at Object.fireWith [as resolveWith] (
jquery-1.11.2.js:3255) at done (jquery-1.11.2.js:9309) at
XMLHttpRequest.callback (jquery-1.11.2.js:9713)
success @ VM4124 datagrid.js:440
fire @ jquery-1.11.2.js:3143
fireWith @ jquery-1.11.2.js:3255
done @ jquery-1.11.2.js:9309
callback @ jquery-1.11.2.js:9713




-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Tue, Jun 13, 2017 at 4:04 PM, Dave Page <dp...@pgadmin.org> wrote:

> Use a more sensible name for Query Tool tabs. Fixes #2482
>
> Branch
> --
> master
>
> Details
> ---
> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=
> 57d866f7b70996a82a881b20248c3285ab3a6900
> Author: Surinder Kumar <surinder.ku...@enterprisedb.com>
>
> Modified Files
> --
> web/pgadmin/browser/templates/browser/js/node.js   |  4 +-
> web/pgadmin/static/css/webcabin.overrides.css  | 13 +
> .../datagrid/templates/datagrid/js/datagrid.js | 58
> --
> .../sqleditor/templates/sqleditor/js/sqleditor.js  |  5 +-
> 4 files changed, 49 insertions(+), 31 deletions(-)
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>


Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-06-14 Thread Harshal Dhumal
On Wed, Jun 14, 2017 at 6:21 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> On Wed, Jun 14, 2017 at 6:19 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Hi,
>>
>> Sorry - it's drifted out again, I suspect because of the work Ashesh
>> has been doing. Can you rebase please? Check with Ashesh first though,
>> in case he's about ready to commit another big change.
>>
> I am not. :-)
>
> Sure, I'll send updated patch.


> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com/>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
>>
>> Thanks.
>>
>> On Fri, Jun 9, 2017 at 10:08 AM, Harshal Dhumal
>> <harshal.dhu...@enterprisedb.com> wrote:
>> > Hi,
>> >
>> >
>> > Please find rebased patch
>> >
>> > --
>> > Harshal Dhumal
>> > Sr. Software Engineer
>> >
>> > EnterpriseDB India: http://www.enterprisedb.com
>> > The Enterprise PostgreSQL Company
>> >
>> > On Thu, Jun 8, 2017 at 6:40 PM, Harshal Dhumal
>> > <harshal.dhu...@enterprisedb.com> wrote:
>> >>
>> >> Ignore this patch.
>> >> Rebase and migration of feature tests and jasmine tests required.
>> >>
>> >> --
>> >> Harshal Dhumal
>> >> Sr. Software Engineer
>> >>
>> >> EnterpriseDB India: http://www.enterprisedb.com
>> >> The Enterprise PostgreSQL Company
>> >>
>> >> On Thu, Jun 8, 2017 at 3:56 PM, Harshal Dhumal
>> >> <harshal.dhu...@enterprisedb.com> wrote:
>> >>>
>> >>> Hi,
>> >>> Please find attached updated patch for feature RM2137.
>> >>>
>> >>> Changes in this patch:
>> >>> 1. Patch rebased.
>> >>>
>> >>> 2. Updated existing feature tests which requires changes due to this
>> >>> feature.
>> >>>  affected feature test cases:
>> >>>  i. PGDataypeFeatureTest
>> >>>  ii. CheckForXssFeatureTest
>> >>>
>> >>> 3. Updated existing jasmine test cases which requires changes due to
>> this
>> >>> feature.
>> >>>  affected jasmine test cases:
>> >>>  i. copy data
>> >>>  ii. range_boundary_navigator
>> >>>  iii. row_selector
>> >>>  iv. set_stages_rows
>> >>>
>> >>> 4. New feature tests added
>> >>> i. on demand result set on scrolling.
>> >>> ii. on demand result set on grid select all.
>> >>> iii. on demand result set on column select all.
>> >>> iv. explain query
>> >>> v. explain query with verbose
>> >>> vi. explain query with costs
>> >>> vii. explain analyze query
>> >>> viii. explain analyze query with buffers
>> >>> ix. explain analyze query with timing
>> >>> x. auto commit disabled.
>> >>> xi. auto commit enabled.
>> >>> xii. auto rollback enabled.
>> >>> xiii. cancel query.
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Harshal Dhumal
>> >>> Sr. Software Engineer
>> >>>
>> >>> EnterpriseDB India: http://www.enterprisedb.com
>> >>> The Enterprise PostgreSQL Company
>> >>>
>> >>> On Tue, May 16, 2017 at 8:14 PM, Dave Page <dp...@pgadmin.org> wrote:
>> >>>>
>> >>>>
>> >>>>
>> >>>> On Mon, May 15, 2017 at 7:40 PM, Harshal Dhumal
>> >>>> <harshal.dhu...@enterprisedb.com> wrote:
>> >>>>>
>> >>>>> Hi,
>> >>>>>
>> >>>>> On Sat, May 13, 2017 at 12:35 AM, Joao Pedro De Almeida Pereira
>> >>>>> <jdealmeidapere...@pivotal.io> wrote:
>> >>>>>>
>> >>>>>> We were only able to apply the patch on 1f903ba2 (were seeing patch
>> >>>>>> does not apply due to sqleditor.js conflicts)
>> >>>>>> The javascript tests passed, but we were unable to copy rows or
>> >>>>>> columns or cells when running the application. Could you run
>> f

Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-06-08 Thread Harshal Dhumal
Ignore this patch.
Rebase and migration of feature tests and jasmine tests required.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Thu, Jun 8, 2017 at 3:56 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
> Please find attached updated patch for feature RM2137.
>
> Changes in this patch:
> 1. Patch rebased.
>
> 2. Updated existing feature tests which requires changes due to this
> feature.
>  affected feature test cases:
>  i. PGDataypeFeatureTest
>  ii. CheckForXssFeatureTest
>
> 3. Updated existing jasmine test cases which requires changes due to this
> feature.
>  affected jasmine test cases:
>  i. copy data
>  ii. range_boundary_navigator
>  iii. row_selector
>  iv. set_stages_rows
>
> 4. New feature tests added
> i. on demand result set on scrolling.
> ii. on demand result set on grid select all.
> iii. on demand result set on column select all.
> iv. explain query
> v. explain query with verbose
> vi. explain query with costs
> vii. explain analyze query
> viii. explain analyze query with buffers
> ix. explain analyze query with timing
> x. auto commit disabled.
>     xi. auto commit enabled.
> xii. auto rollback enabled.
> xiii. cancel query.
>
>
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Tue, May 16, 2017 at 8:14 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>>
>>
>> On Mon, May 15, 2017 at 7:40 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> On Sat, May 13, 2017 at 12:35 AM, Joao Pedro De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
>>>> We were only able to apply the patch on 1f903ba2 (were seeing patch
>>>> does not apply due to sqleditor.js conflicts)
>>>> The javascript tests passed, but we were unable to copy rows or columns
>>>> or cells when running the application. Could you run feature tests?
>>>>
>>> There are three modes sqleditor can be launched
>>> 1. Query tool  (Tools menus -> Query Tool)
>>> 2. Datagrid.  (Right click on any table/view  -> View Data -> View
>>> All/First 100/Last 100/Filtered rows)
>>> 3. Scripts (Right click on any table/view ->
>>> INSERT/CREATE/UPDATE/DELETE/SELECT)
>>>
>>> Paste functionality is only enabled in Datagrid and table has Primary
>>> key otherwise it's disabled. In your case row might have been copied but
>>> you were unable paste because you might be trying to paste the rows in
>>> Query tool. Please try again in Datagrid with table having Primary key.
>>>
>>>
>>>>
>>>> Now that more functionality is being added to sqleditor.js, this may be
>>>> a good time to extract the functionality to separate files. This will
>>>> increase readability, and encourage separation of concerns. It will also
>>>> make changes easier to test in isolation.
>>>>
>>> Ok. Let me check if I can separate out ant functionalities.
>>>
>>>
>>>> It's probably a good idea to test the changes made to the python as
>>>> well as javascript code. In this case, the new behavior of poll() in
>>>> sqleditor __init__ should be tested.
>>>>
>>>
>>> At this point we don't have any python unit tests that can test
>>> sqleditor backend (python code).
>>> @Dave should I include python unit test cases in this patch?
>>>
>>
>> We do have some feature tests that hit the query tool - Murtuza wrote
>> some anti-XSS validation tests for example, and Khushboo has been working
>> on some datatype rendering tests.
>>
>> As a general rule, I prefer we focus more on feature tests now than the
>> API tests - they cover the whole app end-to-end of course. The
>> disadvantages are:
>>
>> - The treeview isn't reliable enough for me to enable those tests on the
>> CI server yet.
>>
>> - They can take a long time to run, so we need to test multiple things at
>> once wherever possible. That means minimising browser reloads, or new
>> instances of tools like the Query Tool - or even the number of queries
>> executed through the query tool as part of a test.
>>
>> That said, yes, if there are specific things that are not covered by
>> Murtuza and Khushboo's 

Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-06-08 Thread Harshal Dhumal
Please find attached rebased patch.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Wed, Jun 7, 2017 at 6:59 PM, Dave Page <dp...@pgadmin.org> wrote:

> Can you rebase this please? I think Ashesh broke it :-p
>
> On Tue, Jun 6, 2017 at 7:42 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > On Mon, Jun 5, 2017 at 9:25 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Hi
> >>
> >> With this patch applied, it uses the field names instead of the labels
> >> in error messages - e.g.
> >>
> >> 'dirty_rate_limit' must be numeric
> >>
> >> instead of:
> >>
> >> 'Dirty Rate Limit (KB)' must be numeric.
> >
> > Fixed. Please find attached updated patch.
> >
> >>
> >>
> >> Thanks.
> >>
> >> On Tue, May 30, 2017 at 8:28 AM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> > Please find updated patch.
> >> >
> >> > --
> >> > Harshal Dhumal
> >> > Sr. Software Engineer
> >> >
> >> > EnterpriseDB India: http://www.enterprisedb.com
> >> > The Enterprise PostgreSQL Company
> >> >
> >> > On Tue, May 30, 2017 at 12:30 PM, Harshal Dhumal
> >> > <harshal.dhu...@enterprisedb.com> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> Please ignore this patch as I forgot to include few changes. I'll
> send
> >> >> updated one.
> >> >>
> >> >> --
> >> >> Harshal Dhumal
> >> >> Sr. Software Engineer
> >> >>
> >> >> EnterpriseDB India: http://www.enterprisedb.com
> >> >> The Enterprise PostgreSQL Company
> >> >>
> >> >> On Mon, May 29, 2017 at 3:18 PM, Harshal Dhumal
> >> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> Here is updated patch for RM2421.
> >> >>>
> >> >>> Now I have moved all Numeric control level validations to datamodel.
> >> >>> As
> >> >>> existing implementation was causing
> >> >>> issues with error messages in create/edit dialog when schema
> contains
> >> >>> two
> >> >>> or more Numeric controls.
> >> >>>
> >> >>> This is generic issue and not related to resource group. Also I have
> >> >>> updated all other nodes which uses Numeric controls
> >> >>>
> >> >>>
> >> >>>
> >> >>> --
> >> >>> Harshal Dhumal
> >> >>> Sr. Software Engineer
> >> >>>
> >> >>> EnterpriseDB India: http://www.enterprisedb.com
> >> >>> The Enterprise PostgreSQL Company
> >> >>>
> >> >>> On Fri, May 19, 2017 at 12:22 PM, Harshal Dhumal
> >> >>> <harshal.dhu...@enterprisedb.com> wrote:
> >> >>>>
> >> >>>> Hi,
> >> >>>>
> >> >>>> On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira
> >> >>>> <jdealmeidapere...@pivotal.io> wrote:
> >> >>>>>
> >> >>>>> Hello Harshal,
> >> >>>>>
> >> >>>>> We review the patch and have some questions:
> >> >>>>> 1) Is there any particular reason to initialize variables and
> >> >>>>> functions
> >> >>>>> in the same place? We believe that it would be more readable there
> >> >>>>> were no
> >> >>>>> chaining of variable creation, specially if those variables are
> >> >>>>> functions.
> >> >>>>> Check line:
> >> >>>>
> >> >>>> That function is only going to be used in checkNumeric function (in
> >> >>>> case
> >> >>>> of Number control) and checkInt function (in case of Integer
> control)
> >> >>>> so
> >> >>>> declared them locally.
> >> >>>> Anyway I'm going to refactor both the controls as Number and
> Integer
> >> >>

Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-06-06 Thread Harshal Dhumal
Hi,

On Mon, Jun 5, 2017 at 9:25 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> With this patch applied, it uses the field names instead of the labels
> in error messages - e.g.
>
> 'dirty_rate_limit' must be numeric
>
> instead of:
>
> 'Dirty Rate Limit (KB)' must be numeric.
>
Fixed. Please find attached updated patch.


>
> Thanks.
>
> On Tue, May 30, 2017 at 8:28 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Please find updated patch.
> >
> > --
> > Harshal Dhumal
> > Sr. Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Tue, May 30, 2017 at 12:30 PM, Harshal Dhumal
> > <harshal.dhu...@enterprisedb.com> wrote:
> >>
> >> Hi,
> >>
> >> Please ignore this patch as I forgot to include few changes. I'll send
> >> updated one.
> >>
> >> --
> >> Harshal Dhumal
> >> Sr. Software Engineer
> >>
> >> EnterpriseDB India: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >>
> >> On Mon, May 29, 2017 at 3:18 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>> Here is updated patch for RM2421.
> >>>
> >>> Now I have moved all Numeric control level validations to datamodel. As
> >>> existing implementation was causing
> >>> issues with error messages in create/edit dialog when schema contains
> two
> >>> or more Numeric controls.
> >>>
> >>> This is generic issue and not related to resource group. Also I have
> >>> updated all other nodes which uses Numeric controls
> >>>
> >>>
> >>>
> >>> --
> >>> Harshal Dhumal
> >>> Sr. Software Engineer
> >>>
> >>> EnterpriseDB India: http://www.enterprisedb.com
> >>> The Enterprise PostgreSQL Company
> >>>
> >>> On Fri, May 19, 2017 at 12:22 PM, Harshal Dhumal
> >>> <harshal.dhu...@enterprisedb.com> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira
> >>>> <jdealmeidapere...@pivotal.io> wrote:
> >>>>>
> >>>>> Hello Harshal,
> >>>>>
> >>>>> We review the patch and have some questions:
> >>>>> 1) Is there any particular reason to initialize variables and
> functions
> >>>>> in the same place? We believe that it would be more readable there
> were no
> >>>>> chaining of variable creation, specially if those variables are
> functions.
> >>>>> Check line:
> >>>>
> >>>> That function is only going to be used in checkNumeric function (in
> case
> >>>> of Number control) and checkInt function (in case of Integer control)
> so
> >>>> declared them locally.
> >>>> Anyway I'm going to refactor both the controls as Number and Integer
> >>>> shares some common properties.
> >>>>
> >>>>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
> >>>>> @@ -1528,7 +1528,18 @@
> >>>>>max_value = field.max,
> >>>>>isValid = true,
> >>>>>intPattern = new RegExp("^-?[0-9]*$"),
> >>>>> -  isMatched = intPattern.test(value);
> >>>>> +  isMatched = intPattern.test(value),
> >>>>> +  trigger_invalid_event = function(msg) {
> >>>>>
> >>>>> 2) The functions added in both places look very similar, can they be
> >>>>> merged and extracted? We are talking about the trigger_invalid_event
> >>>>> function.
> >>>>
> >>>> Yes they can be merged. As of now both NumericControl and
> IntegerControl
> >>>> are derived from InputControl. Ideally
> >>>> only NumericControl should be derived from InputControl and
> >>>> IntegerControl should be derive from NumericControl.
> >>>>
> >>>>
> >>>>>
> >>>>> 3) The following change is very similar to the trigger_invalid_event,
> >>>>> was there a reason not to use it?
> >&g

Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-05-30 Thread Harshal Dhumal
Hi,

Please find updated patch.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Tue, May 30, 2017 at 12:30 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please ignore this patch as I forgot to include few changes. I'll send
> updated one.
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, May 29, 2017 at 3:18 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Here is updated patch for RM2421.
>>
>> Now I have moved all Numeric control level validations to datamodel. As
>> existing implementation was causing
>> issues with error messages in create/edit dialog when schema contains two
>> or more Numeric controls.
>>
>> This is generic issue and not related to resource group. Also I have
>> updated all other nodes which uses Numeric controls
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Fri, May 19, 2017 at 12:22 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira <
>>> jdealmeidapere...@pivotal.io> wrote:
>>>
>>>> Hello Harshal,
>>>>
>>>> We review the patch and have some questions:
>>>> 1) Is there any particular reason to initialize variables and functions
>>>> in the same place? We believe that it would be more readable there were no
>>>> chaining of variable creation, specially if those variables are functions.
>>>> Check line:
>>>>
>>> That function is only going to be used in checkNumeric function (in case
>>> of Number control) and checkInt function (in case of Integer control) so
>>> declared them locally.
>>> Anyway I'm going to refactor both the controls as Number and Integer
>>> shares some common properties.
>>>
>>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>>>> @@ -1528,7 +1528,18 @@
>>>>max_value = field.max,
>>>>isValid = true,
>>>>intPattern = new RegExp("^-?[0-9]*$"),
>>>> -  isMatched = intPattern.test(value);
>>>> +  isMatched = intPattern.test(value),
>>>> +  trigger_invalid_event = function(msg) {
>>>>
>>>> ​
>>>> 2) The functions added in both places look very similar, can they be
>>>> merged and extracted? We are talking about the trigger_invalid_event
>>>>  function.
>>>>
>>> Yes they can be merged. As of now both NumericControl and IntegerControl
>>> are derived from InputControl. Ideally
>>> only NumericControl should be derived from InputControl and
>>> IntegerControl should be derive from NumericControl.
>>>
>>>
>>>
>>>> 3) The following change is very similar to the trigger_invalid_event,
>>>> was there a reason not to use it?
>>>>
>>> Below code triggers "model valid" event; opposite to "model invalid"
>>> event (trigger_invalid_event)
>>>
>>>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>>>> @@ -1573,25 +1584,23 @@
>>>>  this.model.errorModel.unset(name);
>>>>  this.model.set(name, value);
>>>>  this.listenTo(this.model, "change:" + name, this.render);
>>>> -if (this.model.collection || this.model.handler) {
>>>> -  (this.model.collection || this.model.handler).trigger(
>>>> - 'pgadmin-session:model:valid', this.model, 
>>>> (this.model.collection || this.model.handler)
>>>> -);
>>>> +// Check if other fields of same model are valid before
>>>> +// triggering 'session:valid' event
>>>> +if(_.size(this.model.errorModel.attributes) == 0) {
>>>> +  if (this.model.collection || this.model.handler) {
>>>> +(this.model.collection || this.model.handler).trigger(
>>>> +   'pgadmin-session:model:valid', this.model, 
>>>> (this.model.collection || this.model.handler)
>>>> +  );
>>>> +  } el

Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-05-30 Thread Harshal Dhumal
Hi,

Please ignore this patch as I forgot to include few changes. I'll send
updated one.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Mon, May 29, 2017 at 3:18 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Here is updated patch for RM2421.
>
> Now I have moved all Numeric control level validations to datamodel. As
> existing implementation was causing
> issues with error messages in create/edit dialog when schema contains two
> or more Numeric controls.
>
> This is generic issue and not related to resource group. Also I have
> updated all other nodes which uses Numeric controls
>
>
>
> --
> *Harshal Dhumal*
> *Sr. Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, May 19, 2017 at 12:22 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira <
>> jdealmeidapere...@pivotal.io> wrote:
>>
>>> Hello Harshal,
>>>
>>> We review the patch and have some questions:
>>> 1) Is there any particular reason to initialize variables and functions
>>> in the same place? We believe that it would be more readable there were no
>>> chaining of variable creation, specially if those variables are functions.
>>> Check line:
>>>
>> That function is only going to be used in checkNumeric function (in case
>> of Number control) and checkInt function (in case of Integer control) so
>> declared them locally.
>> Anyway I'm going to refactor both the controls as Number and Integer
>> shares some common properties.
>>
>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>>> @@ -1528,7 +1528,18 @@
>>>max_value = field.max,
>>>isValid = true,
>>>intPattern = new RegExp("^-?[0-9]*$"),
>>> -  isMatched = intPattern.test(value);
>>> +  isMatched = intPattern.test(value),
>>> +  trigger_invalid_event = function(msg) {
>>>
>>> ​
>>> 2) The functions added in both places look very similar, can they be
>>> merged and extracted? We are talking about the trigger_invalid_event
>>>  function.
>>>
>> Yes they can be merged. As of now both NumericControl and IntegerControl
>> are derived from InputControl. Ideally
>> only NumericControl should be derived from InputControl and
>> IntegerControl should be derive from NumericControl.
>>
>>
>>
>>> 3) The following change is very similar to the trigger_invalid_event,
>>> was there a reason not to use it?
>>>
>> Below code triggers "model valid" event; opposite to "model invalid"
>> event (trigger_invalid_event)
>>
>>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>>> @@ -1573,25 +1584,23 @@
>>>  this.model.errorModel.unset(name);
>>>  this.model.set(name, value);
>>>  this.listenTo(this.model, "change:" + name, this.render);
>>> -if (this.model.collection || this.model.handler) {
>>> -  (this.model.collection || this.model.handler).trigger(
>>> - 'pgadmin-session:model:valid', this.model, 
>>> (this.model.collection || this.model.handler)
>>> -);
>>> +// Check if other fields of same model are valid before
>>> +// triggering 'session:valid' event
>>> +if(_.size(this.model.errorModel.attributes) == 0) {
>>> +  if (this.model.collection || this.model.handler) {
>>> +(this.model.collection || this.model.handler).trigger(
>>> +   'pgadmin-session:model:valid', this.model, 
>>> (this.model.collection || this.model.handler)
>>> +  );
>>> +  } else {
>>> +(this.model).trigger(
>>> +   'pgadmin-session:valid', this.model.sessChanged(), 
>>> this.model
>>> +  );
>>> +  }
>>>
>>> ​
>>> 4) We also noticed that the following change sets look very similiar. Is
>>> there any reason to have this code duplicated? If not this could be a good
>>> time to refactor it.
>>>
>> As said earlier in response of point 2 code duplication is because the
>> way controls are derived.
>>
>>
>>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>>> @@ -1528,7 +1528,18 @@
>>>
>>> @@ -1573,25 +1584,23 @@
>>>
>>> @@ -1631,7 +1640,18 @@
>>>
>>> @@ -1676,25 +1696,23 @@
>>>
>>> ​
>>>
>>> Thanks
>>> Joao & Shruti
>>>
>>> On Thu, May 18, 2017 at 6:01 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find attached patch for RM2421
>>>>
>>>> Issue fixed: 1. Integer/numeric Validation is not working properly.
>>>> 2. Wrong CPU rate unit
>>>> --
>>>> *Harshal Dhumal*
>>>> *Sr. Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>>
>>>> --
>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>
>>>>
>>>
>>
>


Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-05-29 Thread Harshal Dhumal
Hi,

Here is updated patch for RM2421.

Now I have moved all Numeric control level validations to datamodel. As
existing implementation was causing
issues with error messages in create/edit dialog when schema contains two
or more Numeric controls.

This is generic issue and not related to resource group. Also I have
updated all other nodes which uses Numeric controls



-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Fri, May 19, 2017 at 12:22 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hello Harshal,
>>
>> We review the patch and have some questions:
>> 1) Is there any particular reason to initialize variables and functions
>> in the same place? We believe that it would be more readable there were no
>> chaining of variable creation, specially if those variables are functions.
>> Check line:
>>
> That function is only going to be used in checkNumeric function (in case
> of Number control) and checkInt function (in case of Integer control) so
> declared them locally.
> Anyway I'm going to refactor both the controls as Number and Integer
> shares some common properties.
>
> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>> @@ -1528,7 +1528,18 @@
>>max_value = field.max,
>>isValid = true,
>>intPattern = new RegExp("^-?[0-9]*$"),
>> -  isMatched = intPattern.test(value);
>> +  isMatched = intPattern.test(value),
>> +  trigger_invalid_event = function(msg) {
>>
>> ​
>> 2) The functions added in both places look very similar, can they be
>> merged and extracted? We are talking about the trigger_invalid_event
>>  function.
>>
> Yes they can be merged. As of now both NumericControl and IntegerControl
> are derived from InputControl. Ideally
> only NumericControl should be derived from InputControl and IntegerControl
> should be derive from NumericControl.
>
>
>
>> 3) The following change is very similar to the trigger_invalid_event,
>> was there a reason not to use it?
>>
> Below code triggers "model valid" event; opposite to "model invalid" event
> (trigger_invalid_event)
>
>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>> @@ -1573,25 +1584,23 @@
>>  this.model.errorModel.unset(name);
>>  this.model.set(name, value);
>>  this.listenTo(this.model, "change:" + name, this.render);
>> -if (this.model.collection || this.model.handler) {
>> -  (this.model.collection || this.model.handler).trigger(
>> - 'pgadmin-session:model:valid', this.model, 
>> (this.model.collection || this.model.handler)
>> -);
>> +// Check if other fields of same model are valid before
>> +// triggering 'session:valid' event
>> +if(_.size(this.model.errorModel.attributes) == 0) {
>> +  if (this.model.collection || this.model.handler) {
>> +(this.model.collection || this.model.handler).trigger(
>> +   'pgadmin-session:model:valid', this.model, 
>> (this.model.collection || this.model.handler)
>> +  );
>> +  } else {
>> +(this.model).trigger(
>> +   'pgadmin-session:valid', this.model.sessChanged(), this.model
>> +  );
>> +  }
>>
>> ​
>> 4) We also noticed that the following change sets look very similiar. Is
>> there any reason to have this code duplicated? If not this could be a good
>> time to refactor it.
>>
> As said earlier in response of point 2 code duplication is because the way
> controls are derived.
>
>
>> +++ b/web/pgadmin/static/js/backform.pgadmin.js
>> @@ -1528,7 +1528,18 @@
>>
>> @@ -1573,25 +1584,23 @@
>>
>> @@ -1631,7 +1640,18 @@
>>
>> @@ -1676,25 +1696,23 @@
>>
>> ​
>>
>> Thanks
>> Joao & Shruti
>>
>> On Thu, May 18, 2017 at 6:01 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Please find attached patch for RM2421
>>>
>>> Issue fixed: 1. Integer/numeric Validation is not working properly.
>>> 2. Wrong CPU rate unit
>>> --
>>> *Harshal Dhumal*
>>> *Sr. Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>

Re: [pgadmin-hackers] pgAdmin 4 commit: Cleanup handling of default/null values when data edi

2017-05-28 Thread Harshal Dhumal
Hi,

This commit has some performance issues with row paste functionality.
For 2K copied rows with 3 columns (2 integer and one null column) it took
near about 10 seconds to complete paste operation. And entire application
becomes unresponsive for those 10 seconds.

This is mainly because for each single pasted row entire grid is
re-rendered ( is what I see in code).
Ideally grid should be re-rendered only once after all rows are provided to
grid.

below code snippet from _paste_rows function

_.each(copied_rows, function(row) {
var new_row = arr_to_object(row);
new_row.is_row_copied = true;
row = new_row;
self.temp_new_rows.push(count);
grid.onAddNewRow.notify(
  {item: new_row, column: self.columns[0] , grid:grid}
)
grid.setSelectedRows([]);
count++;
});

The statement

grid.onAddNewRow.notify(
  {item: new_row, column: self.columns[0] , grid:grid}
)

causes grid to re-render (as we listener on onAddNewRow event where we
re-render the grid)
























-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Sun, May 28, 2017 at 12:21 AM, Dave Page <dp...@pgadmin.org> wrote:

> Cleanup handling of default/null values when data editting. FIxes #2400
>
> Branch
> --
> master
>
> Details
> ---
> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=
> 1f26953504a963d2c2223c51f9da29db4d48594b
> Author: Surinder Kumar <surinder.ku...@enterprisedb.com>
>
> Modified Files
> --
> .../static/js/slickgrid/slick.pgadmin.editors.js   |  58 -
> web/pgadmin/tools/sqleditor/command.py |   5 +
> .../sqleditor/templates/sqleditor/js/sqleditor.js  | 254
> -
> 3 files changed, 205 insertions(+), 112 deletions(-)
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>


[pgadmin-hackers] Update pgAdmin4 version on pgadmin.org from 1.4 to 1.5

2017-05-19 Thread Harshal Dhumal
Hi Dave,

Text 1.4 is not updated to 1.5 on pgadmin.org

[image: Inline image 2]
-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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


Re: [pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-05-19 Thread Harshal Dhumal
Hi,

On Thu, May 18, 2017 at 7:57 PM, Joao Pedro De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> Hello Harshal,
>
> We review the patch and have some questions:
> 1) Is there any particular reason to initialize variables and functions in
> the same place? We believe that it would be more readable there were no
> chaining of variable creation, specially if those variables are functions.
> Check line:
>
That function is only going to be used in checkNumeric function (in case of
Number control) and checkInt function (in case of Integer control) so
declared them locally.
Anyway I'm going to refactor both the controls as Number and Integer shares
some common properties.

+++ b/web/pgadmin/static/js/backform.pgadmin.js
> @@ -1528,7 +1528,18 @@
>max_value = field.max,
>isValid = true,
>intPattern = new RegExp("^-?[0-9]*$"),
> -  isMatched = intPattern.test(value);
> +  isMatched = intPattern.test(value),
> +  trigger_invalid_event = function(msg) {
>
> ​
> 2) The functions added in both places look very similar, can they be
> merged and extracted? We are talking about the trigger_invalid_event
> function.
>
Yes they can be merged. As of now both NumericControl and IntegerControl
are derived from InputControl. Ideally
only NumericControl should be derived from InputControl and IntegerControl
should be derive from NumericControl.



> 3) The following change is very similar to the trigger_invalid_event, was
> there a reason not to use it?
>
Below code triggers "model valid" event; opposite to "model invalid" event (
trigger_invalid_event)

> +++ b/web/pgadmin/static/js/backform.pgadmin.js
> @@ -1573,25 +1584,23 @@
>  this.model.errorModel.unset(name);
>  this.model.set(name, value);
>  this.listenTo(this.model, "change:" + name, this.render);
> -if (this.model.collection || this.model.handler) {
> -  (this.model.collection || this.model.handler).trigger(
> - 'pgadmin-session:model:valid', this.model, 
> (this.model.collection || this.model.handler)
> -);
> +// Check if other fields of same model are valid before
> +// triggering 'session:valid' event
> +if(_.size(this.model.errorModel.attributes) == 0) {
> +  if (this.model.collection || this.model.handler) {
> +(this.model.collection || this.model.handler).trigger(
> +   'pgadmin-session:model:valid', this.model, 
> (this.model.collection || this.model.handler)
> +  );
> +  } else {
> +(this.model).trigger(
> +   'pgadmin-session:valid', this.model.sessChanged(), this.model
> +  );
> +  }
>
> ​
> 4) We also noticed that the following change sets look very similiar. Is
> there any reason to have this code duplicated? If not this could be a good
> time to refactor it.
>
As said earlier in response of point 2 code duplication is because the way
controls are derived.


> +++ b/web/pgadmin/static/js/backform.pgadmin.js
> @@ -1528,7 +1528,18 @@
>
> @@ -1573,25 +1584,23 @@
>
> @@ -1631,7 +1640,18 @@
>
> @@ -1676,25 +1696,23 @@
>
> ​
>
> Thanks
> Joao & Shruti
>
> On Thu, May 18, 2017 at 6:01 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find attached patch for RM2421
>>
>> Issue fixed: 1. Integer/numeric Validation is not working properly.
>> 2. Wrong CPU rate unit
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>


[pgadmin-hackers] Fix for RM2421 [pgAdmin4][patch]

2017-05-18 Thread Harshal Dhumal
Hi,

Please find attached patch for RM2421

Issue fixed: 1. Integer/numeric Validation is not working properly.
2. Wrong CPU rate unit
-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
index 3cc822e..596a4ee 100644
--- a/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
+++ b/web/pgadmin/browser/server_groups/servers/resource_groups/templates/resource_groups/js/resource_groups.js
@@ -72,7 +72,7 @@ define(
   id: 'name', label: '{{ _('Name') }}', cell: 'string',
   type: 'text',
 },{
-  id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%%)') }}', cell: 'string',
+  id: 'cpu_rate_limit', label:'{{ _('CPU rate limit (%)') }}', cell: 'string',
   type: 'numeric', min:0, max:16777216
 },{
   id: 'dirty_rate_limit', label:'{{ _('Dirty rate limit (KB)') }}', cell: 'string',
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 553676e..a822da8 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1528,7 +1528,18 @@
   max_value = field.max,
   isValid = true,
   intPattern = new RegExp("^-?[0-9]*$"),
-  isMatched = intPattern.test(value);
+  isMatched = intPattern.test(value),
+  trigger_invalid_event = function(msg) {
+if (this.model.collection || this.model.handler) {
+  (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:invalid', msg, this.model
+);
+} else {
+  (this.model).trigger(
+ 'pgadmin-session:invalid', msg, this.model
+);
+}
+  }.bind(this);
 
   // Below logic will validate input
   if (!isMatched) {
@@ -1573,25 +1584,23 @@
 this.model.errorModel.unset(name);
 this.model.set(name, value);
 this.listenTo(this.model, "change:" + name, this.render);
-if (this.model.collection || this.model.handler) {
-  (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
-);
+// Check if other fields of same model are valid before
+// triggering 'session:valid' event
+if(_.size(this.model.errorModel.attributes) == 0) {
+  if (this.model.collection || this.model.handler) {
+(this.model.collection || this.model.handler).trigger(
+   'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+  );
+  } else {
+(this.model).trigger(
+   'pgadmin-session:valid', this.model.sessChanged(), this.model
+  );
+  }
 } else {
-  (this.model).trigger(
- 'pgadmin-session:valid', this.model.sessChanged(), this.model
-);
+  trigger_invalid_event(_.values(this.model.errorModel.attributes)[0]);
 }
   } else {
-if (this.model.collection || this.model.handler) {
-  (this.model.collection || this.model.handler).trigger(
- 'pgadmin-session:model:invalid', this.model.errorModel.get(name), this.model
-);
-} else {
-  (this.model).trigger(
- 'pgadmin-session:invalid', this.model.errorModel.get(name), this.model
-);
-}
+trigger_invalid_event(this.model.errorModel.get(name));
   }
 }
   });
@@ -1631,7 +1640,18 @@
   max_value = field.max,
   isValid = true,
   intPattern = new RegExp("^-?[0-9]+(\.?[0-9]*)?$"),
-  isMatched = intPattern.test(value);
+  isMatched = intPattern.test(value),
+  trigger_invalid_event = function(msg) {
+if (this.model.collection || this.model.handler) {
+  (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:invalid', msg, this.model
+);
+} else {
+  (this.model).trigger(
+ 'pgadmin-session:invalid', msg, this.model
+);
+}
+  }.bind(this);
 
   // Below logic will validate input
   if (!isMatched) {
@@ -1676,25 +1696,23 @@
 this.model.errorModel.unset(name);
 this.model.set(name, value);
 this.listenTo(this.model, "change:" + name, this.render);
-if (this.model.collection || this.model.handler) {
-  (this.model.c

Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-05-15 Thread Harshal Dhumal
Hi,

On Sat, May 13, 2017 at 12:35 AM, Joao Pedro De Almeida Pereira <
jdealmeidapere...@pivotal.io> wrote:

> We were only able to apply the patch on 1f903ba2 (were seeing patch does
> not apply due to sqleditor.js conflicts)
> The javascript tests passed, but we were unable to copy rows or columns or
> cells when running the application. Could you run feature tests?
>
There are three modes sqleditor can be launched
1. Query tool  (Tools menus -> Query Tool)
2. Datagrid.  (Right click on any table/view  -> View Data -> View
All/First 100/Last 100/Filtered rows)
3. Scripts (Right click on any table/view ->
INSERT/CREATE/UPDATE/DELETE/SELECT)

Paste functionality is only enabled in Datagrid and table has Primary key
otherwise it's disabled. In your case row might have been copied but you
were unable paste because you might be trying to paste the rows in Query
tool. Please try again in Datagrid with table having Primary key.


>
> Now that more functionality is being added to sqleditor.js, this may be a
> good time to extract the functionality to separate files. This will
> increase readability, and encourage separation of concerns. It will also
> make changes easier to test in isolation.
>
Ok. Let me check if I can separate out ant functionalities.


> It's probably a good idea to test the changes made to the python as well
> as javascript code. In this case, the new behavior of poll() in sqleditor
> __init__ should be tested.
>

At this point we don't have any python unit tests that can test sqleditor
backend (python code).
@Dave should I include python unit test cases in this patch?


>
> --Joao and George
>
>
> On Fri, May 12, 2017 at 8:32 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Here is rebased patch.
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Fri, May 12, 2017 at 1:28 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> Pls find updated patch for on demand loading feature.
>>>
>>> Changes:
>>> 1. Added row number.
>>> 2. load renaming result set if user performs select all operation either
>>> on grid or column.
>>> 3. Fixed Row selection issue and row past issue.
>>> 4. Updated existing jasmine test cases.
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Sr. Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Tue, May 9, 2017 at 10:02 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Sr. Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Tue, May 9, 2017 at 1:08 AM, Sarah McAlear <smcal...@pivotal.io>
>>>> wrote:
>>>>
>>>>> Hi Harshal!
>>>>>
>>>>> We applied your patch and ran the Javascript tests and realized there
>>>>> are 6 tests failing. After that we replicate the failures by hand and 
>>>>> found
>>>>> the following issues:
>>>>>
>>>>> - Clicking in the checkboxes of the rows does not select the row
>>>>> anymore.
>>>>> - When copying and pasting (any) data, we realized that it copied an
>>>>> empty dataset.
>>>>>
>>>>> Thanks for pointing out these issues. I have fixed them at my end and
>>>> also remaining tests are failing because in earlier implementation of sql
>>>> editor we have used pain 2Darray to provide data to slick grid and In this
>>>> patch I have used Slick grid DataView
>>>> <https://github.com/mleibman/SlickGrid/wiki/DataView> to provide data
>>>> to slick gird. I'll need to update test cases to support this DataView
>>>> change. I'll send updated patch with all of the above changes along with
>>>> suggestion given by Dave.
>>>>
>>>>
>>>>
>>>>> We didn't review the patch further because there aren't any tests for
>>>>> the newly implemented functionality.
>>>>>
>>>>> Is there a place to find a dataset with 96k rows that you guys were
>>>>> testing with?
>>>>>
&g

Re: [pgadmin-hackers] Re: [pgAdmin4][Patch][RM2399]: Disabled row's background color disappeared on save in View data

2017-05-15 Thread Harshal Dhumal
Hi,

Issue caused because variable temp_new_rows was access before it was
initialised. Attached patch fixes this issue.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Mon, May 15, 2017 at 9:28 PM, Dave Page <dp...@pgadmin.org> wrote:

> Aww, nuts. I thought we had tests for that? Did we miss that particular
> case?
>
> Anyway, copying of a single value still works (with Cmd+C), so I'm not
> inclined to re-wrap everything for this unless someone can get a patch to
> me by ~9AM UK time tomorrow. Surinder?
>
> On Mon, May 15, 2017 at 4:50 PM, Joao Pedro De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hi hackers,
>>
>> We were checking out the selection functionality after this commit--looks
>> like selection no longer works for single cells.
>>
>> If you press a cell in the grid the following message is console logged:
>>
>> sqleditor.js:869 Uncaught TypeError: Cannot read property 'indexOf' of 
>> undefined
>> at SlickGrid. (sqleditor.js:869)
>> at Event.notify (slick.core.js:143)
>> at trigger (slick.grid.js:1067)
>> at setActiveCellInternal (slick.grid.js:2693)
>> at HTMLDivElement.handleClick (slick.grid.js:2469)
>> at HTMLDivElement.dispatch (jquery-1.11.2.js:4665)
>> at HTMLDivElement.$event.dispatch (jquery.event.drag-2.2.js:374)
>> at HTMLDivElement.elemData.handle (jquery-1.11.2.js:4333)
>>
>> ​
>>
>> Thanks
>> George & Joao
>>
>> On Mon, May 15, 2017 at 10:05 AM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> I've committed a modified version of this patch following some
>>> discussion on IM with Surinder.
>>>
>>> Thanks Surinder!
>>>
>>> On Mon, May 15, 2017 at 10:56 AM, Surinder Kumar <
>>> surinder.ku...@enterprisedb.com> wrote:
>>>
>>>> Hi
>>>>
>>>> The regression test cases for 'copy row' was failing.
>>>> This patch was assuming that each selected row will have primary key
>>>> due to selection was not working. Fixed.
>>>>
>>>> Please find revised patch.
>>>>
>>>> Thanks
>>>> Surinder Kumar
>>>>
>>>> On Mon, May 15, 2017 at 1:13 PM, Surinder Kumar <
>>>> surinder.ku...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> This patch contains following changes:
>>>>>
>>>>> 1) When a new row is added, allow to delete if changes are not saved.
>>>>>
>>>>> 2) Disable new row selection if primary key is not given but changes
>>>>> are saved on server.
>>>>>
>>>>> 3) Copy and paste one or more rows, then add new row doesn't
>>>>> work(entered value doesn't appear).
>>>>>
>>>>> 4) After deleting a row, add new row doesn't work.
>>>>>
>>>>> 5) New row added with explicitly given primary key should not disabled.
>>>>>
>>>>>
>>>>> Please review.
>>>>>
>>>>> Thanks,
>>>>> Surinder Kumar
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>
>>>>
>>>
>>>
>>> --
>>> 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
>
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index f3ca7b0..82b966f 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -1597,7 +1597,8 @@ define(
   self.explain_costs = false;
   self.explain_buffers = false;
   self.explain_timing = false;
-  self.is_new_browser_tab = is_new_browser_tab;
+  self.is_new_browser_tab = is_new_browser_tab
+  self.temp_new_rows = [];
 
   // We do not allow to call the start multiple times.
   if (self.gridView)

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [pgAdmin4][PATCH] To fix the issue with Node rename

2017-05-15 Thread Harshal Dhumal
Hi Dave,


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Mon, May 15, 2017 at 1:43 PM, Dave Page <dp...@pgadmin.org> wrote:

> So is the last patch considered good?
>
Except one thing, when user renames server group (note that server group
should never be expanded before renaming) and then expands it by clicking +
icon then it's old name gets restored.

Step:
1. Load application in browser.
2. Do not expand any of the server group.
3. Rename Server group (new name gets updated in tree).
4. Now expand Server group (old name gets restored in tree).

Note that this happens only when Server groups was never expanded before.



>
> On Mon, May 15, 2017 at 9:11 AM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> Yes, It is existing one only, We did not touch on any part of sorting
>> algorithm in this patch.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Mon, May 15, 2017 at 1:24 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Ashesh is out this week. As long as new nodes are sorted with the same
>>> algorithm as existing ones, that's fine.
>>>
>>> On Mon, May 15, 2017 at 8:48 AM, Murtuza Zabuawala <
>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>
>>>> Hi Harshal,
>>>>
>>>> We are using https://github.com/javve/natural-sort for sorting nodes
>>>> which is implemented by Ashesh.
>>>>
>>>> @Ashesh,
>>>> Any suggestion on this?
>>>>
>>>> --
>>>> Regards,
>>>> Murtuza Zabuawala
>>>> EnterpriseDB: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Mon, May 15, 2017 at 1:07 PM, Harshal Dhumal <
>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Murtuza,
>>>>>
>>>>> Currently nodes are sorted in case sensitive manner it should be case
>>>>> insensitive.
>>>>>
>>>>>
>>>>>
>>>>> See current Server group order is A, Servers, a1, a​2. It should be A,
>>>>> a1, a2, Servers.
>>>>> Similarly check sorting order for server and database nodes
>>>>>
>>>>>
>>>>> --
>>>>> *Harshal Dhumal*
>>>>> *Sr. Software Engineer*
>>>>>
>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>> On Fri, May 12, 2017 at 7:08 PM, Murtuza Zabuawala <
>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi Ashesh,
>>>>>>
>>>>>> Please find updated patch as discussed.
>>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Murtuza Zabuawala
>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Fri, May 12, 2017 at 11:37 AM, Murtuza Zabuawala <
>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi Ashesh,
>>>>>>>
>>>>>>> As discussed please find updated patch removing hardcoded check for
>>>>>>> server & server-group node.
>>>>>>>
>>>>>>> --
>>>>>>> Regards,
>>>>>>> Murtuza Zabuawala
>>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>> On Fri, Apr 28, 2017 at 1:29 PM, Murtuza Zabuawala <
>>>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi Ashesh,
>>>>>>>>
>>>>>>>> PFA updated patch for the issue.
>>>>>>>>
>>>>>>>> --
>>>>>>>> Regards,
>>>>>>>> Murtuza Zabuawala
>>>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>
>>>>>>>> On Wed, Apr 26, 2017 at 10:29

Re: [pgadmin-hackers] [pgAdmin4][PATCH] To fix the issue with Node rename

2017-05-15 Thread Harshal Dhumal
Hi Murtuza,

Currently nodes are sorted in case sensitive manner it should be case
insensitive.



See current Server group order is A, Servers, a1, a​2. It should be A, a1,
a2, Servers.
Similarly check sorting order for server and database nodes


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Fri, May 12, 2017 at 7:08 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Ashesh,
>
> Please find updated patch as discussed.
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, May 12, 2017 at 11:37 AM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Hi Ashesh,
>>
>> As discussed please find updated patch removing hardcoded check for
>> server & server-group node.
>>
>> --
>> Regards,
>> Murtuza Zabuawala
>> EnterpriseDB: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Fri, Apr 28, 2017 at 1:29 PM, Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi Ashesh,
>>>
>>> PFA updated patch for the issue.
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Wed, Apr 26, 2017 at 10:29 AM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>> On Mon, Apr 24, 2017 at 4:43 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>
>>>>> Ashesh, can you review/commit this please? Thanks.
>>>>>
>>>>> On Mon, Apr 24, 2017 at 6:17 AM, Murtuza Zabuawala <
>>>>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA minor patch to fix the issue where node rename is not working
>>>>>> properly after 7dd9efd8
>>>>>> <https://redmine.postgresql.org/projects/pgadmin4/repository/revisions/7dd9efd811c7845d9dc985b66f8d33497f2f4bfa>
>>>>>>  commit
>>>>>> .
>>>>>> RM#2355
>>>>>>
>>>>> We should remove the existing node, and then insert at right place
>>>> instead of refreshing the parent.
>>>> Because - that will select the parent node, and not that node, and also
>>>> - it adds overhead of refreshing the whole parent node.
>>>>
>>>> Please send the patch as per our discussion.
>>>>
>>>> -- Thanks, Ashesh
>>>>
>>>>>
>>>>>> --
>>>>>> Regards,
>>>>>> Murtuza Zabuawala
>>>>>> EnterpriseDB: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org
>>>>>> )
>>>>>> To make changes to your subscription:
>>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Dave Page
>>>>> Blog: http://pgsnake.blogspot.com
>>>>> Twitter: @pgsnake
>>>>>
>>>>> EnterpriseDB UK: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>
>>>>
>>>
>>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>


Re: [pgadmin-hackers] pgAdmin 4 commit: Improve handling of nulls and default values in the d

2017-05-12 Thread Harshal Dhumal
Hi,

Below code snippet from above commit assumes that we have to disable last
row after saving.

@@ -2320,6
<https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=blob;f=web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js;h=2062aa2bb909794e5d2c339aec62d2d4e8ffbc28#l2320>
+2340,10
<https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=blob;f=web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js;h=ba9dd4339b8d6287f454ddbde1826be1a2bea0f6;hb=4f9628ed436de53b1ab1a06b123755a86a8f2288#l2340>
@@ define(
   grid.setSelectedRows([]);
 }

+// Add last row(new row) to keep track of it
+if (is_added) {
+  self.rows_to_disable.push(grid.getDataLength()-1);
+}

 However this is not the case all the time

For e.g
Table has some data already and If user adds new row (do not save) and then
copy past few exiting rows (at this point  newly added row no longer
remains at last position). And after saving it disable last row which is
not the newly added row.








-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Fri, May 12, 2017 at 3:24 PM, Dave Page <dp...@pgadmin.org> wrote:

> Improve handling of nulls and default values in the data editor. Fixes
> #2257
>
> Branch
> --
> master
>
> Details
> ---
> https://git.postgresql.org/gitweb?p=pgadmin4.git;a=commitdiff;h=
> 4f9628ed436de53b1ab1a06b123755a86a8f2288
> Author: Surinder Kumar <surinder.ku...@enterprisedb.com>
>
> Modified Files
> --
> .../tables/templates/column/sql/9.2_plus/nodes.sql |  3 +-
> .../tables/templates/column/sql/default/nodes.sql  |  3 +-
> web/pgadmin/static/css/pgadmin.css |  2 +-
> .../static/js/slickgrid/slick.pgadmin.editors.js   | 39 +++---
> .../js/slickgrid/slick.pgadmin.formatters.js   | 46
> --
> web/pgadmin/tools/sqleditor/__init__.py| 25 +++-
> web/pgadmin/tools/sqleditor/command.py | 30 +-
> .../tools/sqleditor/static/css/sqleditor.css   | 12 +-
> .../sqleditor/templates/sqleditor/js/sqleditor.js  | 28 -
> 9 files changed, 163 insertions(+), 25 deletions(-)
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>


Re: [pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-05-09 Thread Harshal Dhumal
Hi,

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Tue, May 9, 2017 at 1:08 AM, Sarah McAlear <smcal...@pivotal.io> wrote:

> Hi Harshal!
>
> We applied your patch and ran the Javascript tests and realized there are
> 6 tests failing. After that we replicate the failures by hand and found the
> following issues:
>
> - Clicking in the checkboxes of the rows does not select the row anymore.
> - When copying and pasting (any) data, we realized that it copied an empty
> dataset.
>
> Thanks for pointing out these issues. I have fixed them at my end and also
remaining tests are failing because in earlier implementation of sql editor
we have used pain 2Darray to provide data to slick grid and In this patch I
have used Slick grid DataView
<https://github.com/mleibman/SlickGrid/wiki/DataView> to provide data to
slick gird. I'll need to update test cases to support this DataView change.
I'll send updated patch with all of the above changes along with suggestion
given by Dave.



> We didn't review the patch further because there aren't any tests for the
> newly implemented functionality.
>
> Is there a place to find a dataset with 96k rows that you guys were
> testing with?
>

Execute below SQL queries to create table dummy_data  with dataset of 100k
records. (you can change number of records to generate by replacing 10
in below SQL query)



*CREATE TABLE public.dummy_data*
*(*
*   id serial NOT NULL, *
*   name text*
*) *
*WITH (*
*  OIDS = FALSE*
*)*
*;*
*ALTER TABLE public.dummy_data*
*  OWNER TO postgres;*


*INSERT INTO public.dummy_data(*
*id, name)*
* SELECT generate_series(1,10), 'dummy name';*







>
> Note: To run the Javascript test you can use the following commands
> ```
> $ cd web
> $ yarn install
> $ yarn run karma start --single-run
> ```
>
> Thanks
> Joao & Sarah
>
> On Mon, May 8, 2017 at 9:16 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Mon, May 8, 2017 at 4:49 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Hi
>>>
>>> This is fantastic! The speedup in the query tool is phenomenal with
>>> large result sets. For 96K rows, I'm now seeing 1 second until I can browse
>>> the data, vs. 13 in v1.4 (and 22 secs in pgAdmin 3)!! Awesome work Harshal
>>> :-)
>>>
>>> Questions/comments:
>>>
>>> - Can we put the row number in the left-hand column, to the right of the
>>> checkbox? This patch highlights just how much value that had in pgAdmin 3
>>> (I hadn't realised we had missed it until now)
>>>
>>> - If the user clicks the checkbox to select all rows, we need to
>>> retrieve them all at that time, otherwise they may be inadvertently working
>>> with a truncated result set.
>>>
>>> Sure I'll do above both the changes.
>>
>>
>>> - Are any changes needed to ensure the Download button works? I'm seeing
>>> missing rows in my test here, but that could be because of the known issues
>>> there with Unicode.
>>>
>>> This is fixed and checked in.
>>
>>
>>
>>> Thanks!
>>>
>>>
>>> On Sun, May 7, 2017 at 6:10 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Here is patch for initial implementation of on demand loading of result
>>>> set for query tool and datagrid.
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Sr. Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Tue, Apr 25, 2017 at 5:21 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>
>>>>> Hi
>>>>>
>>>>> On Tue, Apr 25, 2017 at 8:41 AM, Harshal Dhumal <
>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi Dave,
>>>>>>
>>>>>> To implement feature #2137
>>>>>> <https://redmine.postgresql.org/issues/2137> we'll need to use
>>>>>> server cursor. However server cursor has some
>>>>>> limitation.
>>>>>> For eg.
>>>>>> 1. It cannot execute BEGIN; query (basically user cannot start new

[pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-05-08 Thread Harshal Dhumal
Hi Dave,

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Mon, May 8, 2017 at 4:49 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> This is fantastic! The speedup in the query tool is phenomenal with large
> result sets. For 96K rows, I'm now seeing 1 second until I can browse the
> data, vs. 13 in v1.4 (and 22 secs in pgAdmin 3)!! Awesome work Harshal :-)
>
> Questions/comments:
>
> - Can we put the row number in the left-hand column, to the right of the
> checkbox? This patch highlights just how much value that had in pgAdmin 3
> (I hadn't realised we had missed it until now)
>
> - If the user clicks the checkbox to select all rows, we need to retrieve
> them all at that time, otherwise they may be inadvertently working with a
> truncated result set.
>
> Sure I'll do above both the changes.


> - Are any changes needed to ensure the Download button works? I'm seeing
> missing rows in my test here, but that could be because of the known issues
> there with Unicode.
>
> This is fixed and checked in.



> Thanks!
>
>
> On Sun, May 7, 2017 at 6:10 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Here is patch for initial implementation of on demand loading of result
>> set for query tool and datagrid.
>>
>> --
>> *Harshal Dhumal*
>> *Sr. Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Tue, Apr 25, 2017 at 5:21 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Hi
>>>
>>> On Tue, Apr 25, 2017 at 8:41 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi Dave,
>>>>
>>>> To implement feature #2137 <https://redmine.postgresql.org/issues/2137> 
>>>> we'll
>>>> need to use server cursor. However server cursor has some
>>>> limitation.
>>>> For eg.
>>>> 1. It cannot execute BEGIN; query (basically user cannot start new
>>>> database transaction)
>>>> 2. In case if Auto commit is true then we try to execute user queries
>>>> inside BEGIN and END when ever it's possible even though user has not put
>>>> BEGIN and END in his query.
>>>>
>>>> Also not all queries executed using Query tool produces records as
>>>> result. So can we assume only
>>>> queries started with SELECT should be executed using server cursor to
>>>> support on demand loading.
>>>> Or should we give user an option to use on demand loading like we have
>>>> options for Auto commit? and Auto rollback?
>>>> In case of on demand loading option user will be responsible to execute
>>>> correct queries (queries which can be executed using server cursor)
>>>>
>>>> Let me know your opinion on this.
>>>>
>>>
>>> Hmm, those are good points.
>>>
>>> So, as a first step, there's no absolute requirement to use a server
>>> side cursor here. The results can be materialised in libpq/psycopg2
>>> (perhaps using an async query), then transferred to the client in batches
>>> as described in the ticket.
>>>
>>> I think this would be a significant improvemet - we can re-visit the
>>> possibility of using server side cursors in the future when we have more
>>> ability to parse the query string before executing it (something we will
>>> want to do when we merge query tool/edit grid functionality).
>>>
>>> --
>>> 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
>


[pgadmin-hackers] patch for RM2292 [pgadmin4]

2017-05-08 Thread Harshal Dhumal
Hi,

Pls find patch for RM2292


Changes: While restoring connections after app restart only establish
connection if that
connection was connected previously.


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index e474817..2d2a46c 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -226,6 +226,7 @@ class Connection(BaseConnection):
 res['conn_id'] = self.conn_id
 res['database'] = self.db
 res['async'] = self.async
+res['wasConnected'] = self.wasConnected
 
 return res
 
@@ -1565,15 +1566,18 @@ WHERE db.oid = {0}""".format(did))
 self, conn_info['conn_id'], conn_info['database'],
 True, conn_info['async']
 )
-
-try:
-conn.connect(
-password=data['password'],
-server_types=ServerType.types()
-)
-except Exception as e:
-current_app.logger.exception(e)
-self.connections.pop(conn_info['conn_id'])
+# only try to reconnect if connection was connected previously.
+if conn_info['wasConnected']:
+try:
+conn.connect(
+password=data['password'],
+server_types=ServerType.types()
+)
+# This will also update wasConnected flag in connection so
+# no need to update the flag manually.
+except Exception as e:
+current_app.logger.exception(e)
+self.connections.pop(conn_info['conn_id'])
 
 def release(self, database=None, conn_id=None, did=None):
 if did is not None:

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Fix for csv download issue [RM2253] [RM2214] [pgadmin4]

2017-05-08 Thread Harshal Dhumal
Hi,

Pls find attached patch for csv download issue when data contains non ASCII
characters. And also when table name contains non ASCII characters

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index d114988..cdd790e 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -12,6 +12,7 @@ import simplejson as json
 import os
 import pickle
 import random
+import time
 
 from flask import Response, url_for, render_template, session, request
 from flask_babel import gettext
@@ -1372,9 +1373,12 @@ def start_query_download_tool(trans_id):
 r = Response(gen(), mimetype='text/csv')
 
 if 'filename' in data and data['filename'] != "":
-filename = data['filename']
+# Response headers only support latin-1 compatible strings.
+try:
+filename = data['filename'].encode('latin-1', 'strict')
+except UnicodeEncodeError:
+filename = str(int(time.time())) + ".csv"
 else:
-import time
 filename = str(int(time.time())) + ".csv"
 
 r.headers["Content-Disposition"] = "attachment;filename={0}".format(filename)
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index e474817..ff74eb7 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -648,7 +648,10 @@ WHERE
 res_io, fieldnames=header, delimiter=str(','), quoting=csv.QUOTE_NONNUMERIC
 )
 csv_writer.writeheader()
-csv_writer.writerows(results)
+# convert unicode records to utf-8 as csv writer do not support
+# writing unicode data
+csv_writer.writerows([{k: v.encode('utf-8') for k, v in row.items()}
+  for row in results])
 
 yield res_io.getvalue()
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Re: Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-05-07 Thread Harshal Dhumal
Hi,

Here is patch for initial implementation of on demand loading of result set
for query tool and datagrid.

-- 
*Harshal Dhumal*
*Sr. Software Engineer*

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

On Tue, Apr 25, 2017 at 5:21 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Tue, Apr 25, 2017 at 8:41 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>>
>> To implement feature #2137 <https://redmine.postgresql.org/issues/2137> we'll
>> need to use server cursor. However server cursor has some
>> limitation.
>> For eg.
>> 1. It cannot execute BEGIN; query (basically user cannot start new
>> database transaction)
>> 2. In case if Auto commit is true then we try to execute user queries
>> inside BEGIN and END when ever it's possible even though user has not put
>> BEGIN and END in his query.
>>
>> Also not all queries executed using Query tool produces records as
>> result. So can we assume only
>> queries started with SELECT should be executed using server cursor to
>> support on demand loading.
>> Or should we give user an option to use on demand loading like we have
>> options for Auto commit? and Auto rollback?
>> In case of on demand loading option user will be responsible to execute
>> correct queries (queries which can be executed using server cursor)
>>
>> Let me know your opinion on this.
>>
>
> Hmm, those are good points.
>
> So, as a first step, there's no absolute requirement to use a server side
> cursor here. The results can be materialised in libpq/psycopg2 (perhaps
> using an async query), then transferred to the client in batches as
> described in the ticket.
>
> I think this would be a significant improvemet - we can re-visit the
> possibility of using server side cursors in the future when we have more
> ability to parse the query string before executing it (something we will
> want to do when we merge query tool/edit grid functionality).
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/config.py b/web/config.py
index 5ff9748..f89dc89 100644
--- a/web/config.py
+++ b/web/config.py
@@ -324,6 +324,12 @@ THREADED_MODE = True
 SQLALCHEMY_TRACK_MODIFICATIONS = False
 
 ##
+# Number of records to fetch in one batch in query tool when query result
+# set is large.
+##
+ON_DEMAND_RECORD_COUNT = 1000
+
+##
 # Local config settings
 ##
 
diff --git a/web/pgadmin/static/js/selection/copy_data.js b/web/pgadmin/static/js/selection/copy_data.js
index 018efea..c549563 100644
--- a/web/pgadmin/static/js/selection/copy_data.js
+++ b/web/pgadmin/static/js/selection/copy_data.js
@@ -11,13 +11,13 @@ define([
 var grid = self.slickgrid;
 var columnDefinitions = grid.getColumns();
 var selectedRanges = grid.getSelectionModel().getSelectedRanges();
-var data = grid.getData();
+var dataView = grid.getData();
 var rows = grid.getSelectedRows();
 
 
 if (allTheRangesAreFullRows(selectedRanges, columnDefinitions)) {
   self.copied_rows = rows.map(function (rowIndex) {
-return data[rowIndex];
+return grid.getDataItem(rowIndex);
   });
   setPasteRowButtonEnablement(self.can_edit, true);
 } else {
@@ -25,7 +25,7 @@ define([
   setPasteRowButtonEnablement(self.can_edit, false);
 }
 
-var csvText = rangeBoundaryNavigator.rangesToCsv(data, columnDefinitions, selectedRanges);
+var csvText = rangeBoundaryNavigator.rangesToCsv(dataView.getItems(), columnDefinitions, selectedRanges);
 if (csvText) {
   clipboard.copyTextToClipboard(csvText);
 }
diff --git a/web/pgadmin/static/js/selection/row_selector.js b/web/pgadmin/static/js/selection/row_selector.js
index 76a8c1a..b166edc 100644
--- a/web/pgadmin/static/js/selection/row_selector.js
+++ b/web/pgadmin/static/js/selection/row_selector.js
@@ -15,9 +15,11 @@ define(['jquery', 'sources/selection/range_selection_helper', 'slickgrid'], func
   if (grid.getColumns()[args.cell].id === 'row-header-column') {
 if (event.target.type != "checkbox") {
   var checkbox = $(event.target).find('input[type="checkbox"]');
-  toggleCheckbox($(checkbox));
+  if (checkbox.length > 0) {
+toggleCheckbox($(checkbox));
+updateRanges(grid, args.row);
+  }
 }
-updateRanges(grid, args.row);
   

[pgadmin-hackers] Server side cursor limitations for on demand loading of data in query tool [RM2137] [pgAdmin4]

2017-04-25 Thread Harshal Dhumal
Hi Dave,

To implement feature #2137 <https://redmine.postgresql.org/issues/2137> we'll
need to use server cursor. However server cursor has some
limitation.
For eg.
1. It cannot execute BEGIN; query (basically user cannot start new database
transaction)
2. In case if Auto commit is true then we try to execute user queries
inside BEGIN and END when ever it's possible even though user has not put
BEGIN and END in his query.

Also not all queries executed using Query tool produces records as result.
So can we assume only
queries started with SELECT should be executed using server cursor to
support on demand loading.
Or should we give user an option to use on demand loading like we have
options for Auto commit? and Auto rollback?
In case of on demand loading option user will be responsible to execute
correct queries (queries which can be executed using server cursor)

Let me know your opinion on this.



-- 
*Harshal Dhumal*
*Software Engineer*

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


[pgadmin-hackers] Re: [pgAdmin 4 - Bug #2274] Row Deletion Against Tables With PKs Not at Ordinal 0 Position Fail

2017-03-24 Thread Harshal Dhumal
Hi,

Here is patch for RM2274 (patch credits to Wayne Winch Jr)

I tested this patch with below scenarios and all are working fine:

1. Table with 2 columns with 2nd col as primary key.
2. Table with 3 columns with 3rd and 2nd cols as primary key.
3. Table with 4 columns with 3rd and 2nd and 4th cols as primary key.
4. Table with 4 columns with 2nd and 4th cols as primary key.
5. Table with 4 columns with 4th col as primary key.
6. Table with 4 columns with 1st col as primary key.



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Mar 22, 2017 at 3:27 PM, <redm...@postgresql.org> wrote:

> Issue #2274 has been updated by Dave Page.
>
>- *Priority* changed from *Normal* to *Urgent*
>- *Target version* set to *1.4*
>
> --
> Bug #2274: Row Deletion Against Tables With PKs Not at Ordinal 0 Position
> Fail <https://redmine.postgresql.org/issues/2274#change-6260>
>
>- Author: Wayne Winch Jr
>- Status: New
>- Priority: Urgent
>- Assignee:
>- Category:
>- Target version: 1.4
>- Platform:
>- Area: User Interface
>
> If pgAdmin4 is used to delete one or more rows for tables having primary
> keys that do not occupy the first column(s) of said table, the deletion
> will fail with Python error --
>
> File 
> "/usr/lib/python3.5/site-packages/pgadmin4-web/pgadmin/tools/sqleditor/command.py",
> line 499, in save
> row[keys[int(k)]] = v
> IndexError: list index out of range
>
> SIDE NOTE: A separate problem exists whereby pgAdmin4 does not adequately
> indicate that an internal error (as listed above) has occurred as it merely
> switches from the Data Output tab to the Messages tab whereby an old
> message unrelated to the current or any exception is unhelpfully shown.
>
> The row deletion problem is caused by faulty logic within the command.py
> file, TableCommand class, save() method in the 'deleted' operation branch
> (Line 499) as indicated in the stack trace:
>
> row[keys[int(k)]] = v
>
> By changing this line to the following, the index mapping is performed
> correctly (by bypassing keys list) for tables with non-ordinal, zero-based
> PK column(s):
>
> row[changed_data['columns'][int(k)]['name']] = v
>
> This problem seems to have been introduced in pgAdmin4v1.3.
> --
>
> You have received this notification because you have either subscribed to
> it, or are involved in it.
> To change your notification preferences, please click here:
> https://redmine.postgresql.org/my/account
>
diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py
index 9420e08..be7f21f 100644
--- a/web/pgadmin/tools/sqleditor/command.py
+++ b/web/pgadmin/tools/sqleditor/command.py
@@ -496,7 +496,7 @@ class TableCommand(GridCommand):
 for k, v in row.items():
 # Set primary key with label & delete index based mapped key
 try:
-row[keys[int(k)]] = v
+row[changed_data['columns'][int(k)]['name']] = v
 except ValueError:
 continue
 del row[k]

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] [RM2283] [pgAdmin4] minor patch for select2 cell

2017-03-23 Thread Harshal Dhumal
Hi,

PFA minor patch for RM2283.

Issue: When setting default selection of multiple values we need to check
if select2 cell is in multiselect mode. We need to check this as javascript
assumes string as array of chars and tries to set individual char as
selected option in cell.


RM2283.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] patch for RM2243 and RM2244 [pgAdmin4]

2017-03-21 Thread Harshal Dhumal
Hi,

Please find updated patch for RM2244.

Changes: View Data was broken in last patch when table contains more that 1
column.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Mar 20, 2017 at 4:10 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Sat, Mar 18, 2017 at 2:57 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> >
> > Please find attached patch for RM2244.
>
> If I run View Data on the table below, I see the following exception
> and no grid is rendered:
>
> CREATE TABLE public.varchar_test
> (
> id integer NOT NULL DEFAULT nextval('varchar_test_id_seq'::regclass),
> data character varying(10) COLLATE pg_catalog."default",
> CONSTRAINT varchar_test_pkey PRIMARY KEY (id)
> )
> WITH (
> OIDS = FALSE
> )
> TABLESPACE pg_default;
>
> ALTER TABLE public.varchar_test
> OWNER to postgres;
>
>
>
>
> 2017-03-20 10:37:49,711: SQL pgadmin: Execute (async) for server #1 -
> CONN:1470698 (Query-id: 4557394):
> SELECT * FROM public.varchar_test
> ORDER BY id ASC
> 2017-03-20 10:37:49,714: INFO werkzeug: 127.0.0.1 - - [20/Mar/2017
> 10:37:49] "GET /sqleditor/view_data/start/2408862 HTTP/1.1" 200 -
> 2017-03-20 10:37:49,749: SQL pgadmin: Polling result for (Query-id:
> 4557394)
> 2017-03-20 10:37:49,749: SQL pgadmin: Status message for (Query-id:
> 4557394)
> 2017-03-20 10:37:49,750: INFO werkzeug: 127.0.0.1 - - [20/Mar/2017
> 10:37:49] "GET /sqleditor/poll/2408862 HTTP/1.1" 200 -
> 2017-03-20 10:37:49,779: INFO werkzeug: 127.0.0.1 - - [20/Mar/2017
> 10:37:49] "GET /sqleditor/columns/2408862 HTTP/1.1" 200 -
> 2017-03-20 10:37:49,808: SQL pgadmin: Execute (dict) for server #1 -
> CONN:1470698 (Query-id: 9451779):
> SELECT oid, format_type(oid,null) as typname FROM pg_type WHERE oid IN
> (%s) ORDER BY oid;
>
> 2017-03-20 10:37:49,814: INFO werkzeug: 127.0.0.1 - - [20/Mar/2017
> 10:37:49] "GET /sqleditor/fetch/types/2408862 HTTP/1.1" 500 -
> Traceback (most recent call last):
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/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-
> packages/flask_login.py",
> line 792, in decorated_view
> return func(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/tools/sqleditor/__
> init__.py",
> line 558, in fetch_pg_types
> """, tuple(oid))
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/
> psycopg2/__init__.py",
> line 938, in execute_dict
> self.__internal_blocking_execute(cur, query, params)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/
> psycopg2/__init__.py",
> line 595, in __internal_blocking_execute
> cur.execute(query, params)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/utils/driver/
> psycopg2/cursor.py",
> line 176, in execute
> return _cursor.execute(self, query, params)
> TypeError: not all arguments converted during string formatting
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/tools/

Re: [pgadmin-hackers] patch for RM2243 and RM2244 [pgAdmin4]

2017-03-18 Thread Harshal Dhumal
Hi,

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Mar 17, 2017 at 4:04 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Fri, Mar 17, 2017 at 7:02 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Here is patch for RM2243 and RM2244
> >
> > Changes: 1. Pickup correct encoding in qtLiteral to decode.
> > 2. While releasing database connection only decode database name if it's
> not
> > unicode.
>
> This fixes 2243, but 2244 is an SQL error that occurs when querying
> tables with no columns in the Query Tool. Although Fahar found it
> whilst testing with an Arabic name, it's otherwise unrelated.
>
> Patch committed to fix 2243 only.
>
>
Yes right, I missed that. I thought 2244 was also related to encoding.

Please find attached patch for RM2244.



> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


RM2244.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] patch for RM2243 and RM2244 [pgAdmin4]

2017-03-17 Thread Harshal Dhumal
Hi,

Here is patch for RM2243 and RM2244

Changes: 1. Pickup correct encoding in qtLiteral to decode.
2. While releasing database connection only decode database name if it's
not unicode.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 18be00ed..ae133559 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -1576,7 +1576,8 @@ WHERE db.oid = {0}""".format(did))
 if did is not None:
 if did in self.db_info and 'datname' in self.db_info[did]:
 database = self.db_info[did]['datname']
-if hasattr(str, 'decode'):
+if hasattr(str, 'decode') and \
+not isinstance(database, unicode):
 database = database.decode('utf-8')
 if database is None:
 return False
@@ -1838,10 +1839,7 @@ class Driver(BaseDriver):
 # Returns in bytes, we need to convert it in string
 if isinstance(res, bytes):
 try:
-try:
-res = res.decode()
-except UnicodeDecodeError:
-res = res.decode(sys.getfilesystemencoding())
+res = res.decode()
 except UnicodeDecodeError:
 res = res.decode('utf-8')
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Numeric controls validation issue in nested schema [pgAdmin4]

2017-03-09 Thread Harshal Dhumal
Hi,

PFA minor patch for numeric control .

This Fixes #2241


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 9722480..553676e 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1573,6 +1573,15 @@
 this.model.errorModel.unset(name);
 this.model.set(name, value);
 this.listenTo(this.model, "change:" + name, this.render);
+if (this.model.collection || this.model.handler) {
+  (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+);
+} else {
+  (this.model).trigger(
+ 'pgadmin-session:valid', this.model.sessChanged(), this.model
+);
+}
   } else {
 if (this.model.collection || this.model.handler) {
   (this.model.collection || this.model.handler).trigger(
@@ -1667,6 +1676,15 @@
 this.model.errorModel.unset(name);
 this.model.set(name, value);
 this.listenTo(this.model, "change:" + name, this.render);
+if (this.model.collection || this.model.handler) {
+  (this.model.collection || this.model.handler).trigger(
+ 'pgadmin-session:model:valid', this.model, (this.model.collection || this.model.handler)
+);
+} else {
+  (this.model).trigger(
+ 'pgadmin-session:valid', this.model.sessChanged(), this.model
+);
+}
   } else {
 if (this.model.collection || this.model.handler) {
   (this.model.collection || this.model.handler).trigger(

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch from RM1983 [pgAdmin4]

2017-02-27 Thread Harshal Dhumal
Hi,

Please find updated patch for encoding issue.

Apart from encoding issue I have also fixed issue of wrong data was show in
query editor for string types and array string types for databases with
encoding other than utf-8.



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Feb 24, 2017 at 4:41 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Thu, Feb 23, 2017 at 10:34 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Please find updated patch for unicode issue on python 2.7
> >
> > I have tested with below scenarios for all nodes (except database and
> > Login/Group Role as these are stored in shared catalogs as for now we are
> > not considering encoding issues for these two nodes)
>
> This breaks on my PG 9.4 server - I'm unable to open the Databases
> node. That server has both databases with Unicode names, and databases
> in encodings other than UTF-8.
>
> (hat-tip to George and Atira; it was their feature tests that showed
> up this problem :-) )
>
> 2017-02-24 11:08:26,379: INFO werkzeug: 127.0.0.1 - - [24/Feb/2017
> 11:08:26] "GET /browser/database/nodes/1/1/ HTTP/1.1" 500 -
> Traceback (most recent call last):
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/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-
> packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line
> 235, in dispatch_request
> return method(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/__init__.py",
> line 151, in wrapped
> return f(self, *args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/__init__.py",
> line 228, in nodes
> res = self.get_nodes(gid, sid)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/__init__.py",
> line 198, in get_nodes
> dbname = dbname.decode('utf-8')
>   File "/System/Library/Frameworks/Python.framework/Versions/2.7/
> lib/python2.7/encodings/utf_8.py",
> line 16, in decode
> return codecs.utf_8_decode(input, errors, True)
> UnicodeEncodeError: 'ascii' codec can't encode characters in position
> 0-5: ordinal not in range(128)
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 88360dd..4ba9d88 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -194,8 +194,6 @@ class DatabaseView(PGChildNodeView):
 
 for row in rset['rows']:
 dbname = row['name']
-if hasattr(str, 'decode'):
-dbname = dbname.decode('utf-8')
 if self.manager.db == dbname:
 connected = True
 canDrop = canDisConn = False
@@ 

Re: [pgadmin-hackers] Patch from RM1983 [pgAdmin4]

2017-02-23 Thread Harshal Dhumal
Hi,

Please find updated patch for unicode issue on python 2.7

I have tested with below scenarios for all nodes (except database and
Login/Group Role as these are stored in shared catalogs as for now we are
not considering encoding issues for these two nodes)

scenarios: Create and Update nodes


Note: Apply patches which I have just sent (with subject pgAdmin4 minor
issues [pgAdmin4]) before applying this patch.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Feb 17, 2017 at 4:22 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Harshal,
>
> *Python3.5*
> 1) I installed PG_9.4 with locale: Arabic, Saudi Arabia,
> - When I try to create new database with name "السلام" -> with 'template
> 0' as template , it fails to open, see screenshot
> - Backup/Restore fails, refer screenshot
>
> I tested INSET/UPDATE/DELETE and other common operations and seems to be
> working.
> Attaching screenshots.
>
>
> 2) I installed PG_9.5 with locale: Chinese, China
> - I am not able to create new DB with Chinese name same as above mentioned
> Same as (1), most parts are working with patch
> Attaching screenshots.
>
> 3) I installed PG_9.5 with locale: Japanese, Japan
> - I am not able to create new DB with Japanese name same as above mentioned
> Same as (1), most parts are working with patch
> Attaching screenshots.
>
>
> *Python2.7 w**ith 3 server mentioned above*
> Works fine most the places but also fails at some places with Unicode
> errors, As I observed it fails when we receive the data from DB server (by
> running properties.sql) and we try to render the data in template as we
> received from DB server.
> Screenshots attached.
>
> *Common Exceptions:*
>
>{{conn|qtIdent(c.name)}} {{ GET_TYPE.CREATE_TYPE_SQL(conn, c.cltype,
> c.attlen, c.attprecision, c.hasSqrBracket) }}{% if c.collspcname %} COLLATE
> {{c.collspcname}}{% endif %}{% if c.attnotnull %} NOT NULL{% endif %}{% if
> c.defval %} DEFAULT {{c.defval}}{% endif %}
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 10:
> ordinal not in range(128)
> Traceback (most recent call last):
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/app.py",
> line 1625, in dispatch_request
> return self.view_functions[rule.endpoint](**req.view_args)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
>   File "/home/murtuza/projects/pgadmin4/web/pgadmin/browser/utils.py",
> line 235, in dispatch_request
> return method(*args, **kwargs)
>   File "/home/murtuza/projects/pgadmin4/web/pgadmin/browser/
> server_groups/servers/databases/schemas/functions/__init__.py", line 341,
> in wrap
> return f(*args, **kwargs)
>   File "/home/murtuza/projects/pgadmin4/web/pgadmin/browser/
> server_groups/servers/databases/schemas/functions/__init__.py", line
> 1021, in sql
> query_for="sql_panel")
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/templating.py",
> line 134, in render_template
> context, ctx.app)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-packages/flask/templating.py",
> line 116, in _render
> rv = template.render(context)
>   File 
> "/home/murtuza/projects/venv2/lib/python2.7/site-pack

[pgadmin-hackers] pgAdmin4 mirror issues [pgAdmin4]

2017-02-23 Thread Harshal Dhumal
Hi,

While fixing and testing Unicode issues throughout pgadmin4 nodes I found
bellow issues (other than Unicode) which was preventing me further testing.
So these need to checked in first before we can apply Unicode related issue
patch.

1. *event_trigger_sql.patch*: returns correct value of 'eventfunname' when
schema of of trgger function is other than public.

2.*check_constraint_sql.patch*: Wrong sql was generated for check
constraint when we rename table name and check name at the same time from
table edit mode.

3.*dependents_sql*.patch: dependents sql was failing because of following
issue.
On non utf-8 encoding database bellow type casting queries fail as it
treats 0 (zero) as null instead of integer.

SELECT 0::text;

SELECT CAST(0 AS text);

db error:
ERROR:  null character not permitted

** Error **

ERROR: null character not permitted
SQL state: 54000




-- 

*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql
index 662d04b..e7b81af 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql
@@ -1,7 +1,12 @@
 SELECT e.oid, e.xmin, e.evtname AS name, upper(e.evtevent) AS eventname,
 pg_catalog.pg_get_userbyid(e.evtowner) AS eventowner,
 e.evtenabled AS enabled,
-e.evtfoid AS eventfuncoid, quote_ident(n.nspname) || '.' || e.evtfoid::regproc AS eventfunname,
+e.evtfoid AS eventfuncoid,
+CASE
+  WHEN n.nspname = 'public'
+  THEN quote_ident(n.nspname) || '.' || cast(e.evtfoid::regproc as text)
+  ELSE cast(e.evtfoid::regproc as text)
+END AS  eventfunname,
 array_to_string(array(select quote_literal(x) from unnest(evttags) as t(x)), ', ') AS when,
  pg_catalog.obj_description(e.oid, 'pg_event_trigger') AS comment,
  (SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=e.oid) AS seclabels,
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
index 6c27923..da1c8ef 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/check_constraint/sql/9.2_plus/update.sql
@@ -1,13 +1,13 @@
 {% if data %}
 {% if data.name != o_data.name %}
-ALTER TABLE {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
+ALTER TABLE {{ conn|qtIdent(o_data.nspname, data.table) }}
 RENAME CONSTRAINT {{ conn|qtIdent(o_data.name) }} TO {{ conn|qtIdent(data.name) }};{% endif -%}
 {% if 'convalidated' in data and o_data.convalidated != data.convalidated and not data.convalidated %}
 
-ALTER TABLE {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
+ALTER TABLE {{ conn|qtIdent(o_data.nspname, data.table) }}
 VALIDATE CONSTRAINT {{ conn|qtIdent(data.name) }};{% endif -%}
 {% if data.comment is defined and data.comment != o_data.comment %}
 
-COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(o_data.nspname, o_data.relname) }}
+COMMENT ON CONSTRAINT {{ conn|qtIdent(data.name) }} ON {{ conn|qtIdent(o_data.nspname, data.table) }}
 IS {{ data.comment|qtLiteral }};{% endif %}
 {% endif -%}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
index 881e1eb..e2ba3d6 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
+++ b/web/pgadmin/browser/server_groups/servers/templates/depends/sql/default/dependents.sql
@@ -1,6 +1,6 @@
 {% if fetch_dependencies %}
 SELECT DISTINCT dep.deptype, dep.refclassid, cl.relkind, ad.adbin, ad.adsrc,
-CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::text, '')
+CASE WHEN cl.relkind IS NOT NULL THEN cl.relkind || COALESCE(dep.refobjsubid::character varying, '')
 WHEN tg.oid IS NOT NULL THEN 'T'::text
 WHEN ty.oid IS NOT NULL AND ty.typbasetype = 0 THEN 'y'::text
 WHEN ty.oid IS NOT NULL AND ty.typbasetype != 0 THEN 'd'::text

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch from RM1983 [pgAdmin4]

2017-02-06 Thread Harshal Dhumal
Hi Dave,

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Feb 6, 2017 at 6:48 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Mon, Feb 6, 2017 at 12:57 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Please find attached patch for RM 1983.
> >
> > This issue only occurs when database encoding is other than utf-8
> >
> > Also other issue was when we use connection of database with encoding
> other
> > than utf-8 to retrieve data from cluster table/s which has encoding utf-8
> > (e.g. pg_database) then data was not decoded properly.
>
> The code makes an assumption that pg_database is always utf-8 encoded.
> I don't believe that is correct - I believe it's the encoding used in
> the database from which the new database was created. The general
> advice is that users should avoid using non-7bit ASCII characters in
> shared catalogs, e.g. databases and comments etc.
>

Ok.

Let me split this into two issues:
i) RM1983 for which I have attached updated patch. (basically I removed
changes related to decode data retried from pg_database when connection
encoding is other than utf-8)
ii) Support to allow user to use non- ASCII characters in shared
catalogs with the help of pgAdmin4.

Regarding your statement about pg_database *"I believe it's the encoding
used in the database from which the new database was created."**. *I found
it little-bit confusing for me (correct me if i'm wrong); As mentioned here
<https://www.postgresql.org/docs/9.5/static/catalog-pg-database.html> there
is only one copy of pg_database per cluster. So I assume pg_database is
created when we initialize database cluster and not when we create new
database.



>
> See https://www.postgresql.org/message-id/flat/20160216163833.GF31273%
> 40momjian.us#20160216163833.gf31...@momjian.us
> for more info for example.
>
> Did pgAdmin 3 just assume it was UTF-8? I suspect it did - and that
> just happened to work in most cases.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 4cafeb2..4e460a6 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -26,7 +26,7 @@ from flask import g, current_app, session
 from flask_babel import gettext
 from flask_security import current_user
 from pgadmin.utils.crypto import decrypt
-from psycopg2.extensions import adapt
+from psycopg2.extensions import adapt, encodings
 
 import config
 from pgadmin.model import Server, User
@@ -74,6 +74,7 @@ psycopg2.extensions.register_type(
 'NUMERIC_RANGE_TEXT', psycopg2.STRING)
 )
 
+
 def register_string_typecasters(connection):
 """
 Casts various types to string, resolving issues with out of
@@ -94,6 +95,30 @@ def register_string_typecasters(connection):
 new_type = psycopg2.extensions.new_type(oids, 'RETURN_STRING', return_as_string)
 psycopg2.extensions.register_type(new_type)
 
+# In python3 when database encoding is other than utf-8 and client encoding
+# is set to UNICODE then we need to map data from database encoding
+# to utf-8.
+# This is required because when client encoding is set to UNICODE then
+# psycopg assumes database encoding utf-8 and not the actual encoding.
+# Not sure whether it's bug or feature in psycopg for python3.
+
+if sys.version_info >= (3,) and connection.encoding != 'UTF8':
+def return_as_unicode(value, cursor):
+if value is None:
+return None
+# Treat value as byte sequence of database encoding and then decode
+# it as utf-8 to get correct unicode value.
+return bytes(
+value, encodings[cursor.connection.encoding]
+).decode('utf-8')
+
+unicode_type = psycopg2.extensions.new_type(
+(19, 18, 25, 1042, 1043, 0),
+'UNICODE', return_as_unicode)
+
+psycopg2.extensions.register_type(unicode_type)
+
+
 class Connection(BaseConnection):
 """
 class Connection(object)
@@ -568,11 +593,17 @@ WHERE
 query: SQL query to run.
 params: Extra parameters
 """
+
+if sys.version_info < (3,):
+if type(query) == unicode:
+query = query.encode('utf-8')
+else:
+query = query.encode('utf-8')
+
 cur.execute(query, params)
 if self.async == 1:
 self._wait(cur.connection)
 
-
 def execute_on_server_as_csv(self, query, params=None, formatted_exce

[pgadmin-hackers] Patch from RM1983 [pgAdmin4]

2017-02-06 Thread Harshal Dhumal
Hi,

Please find attached patch for RM 1983.

This issue only occurs when database encoding is other than utf-8

Also other issue was when we use connection of database with encoding other
than utf-8 to retrieve data from cluster table/s which has encoding utf-8
(e.g. pg_database) then data was not decoded properly.



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 88360dd..df325e1 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -9,6 +9,7 @@
 
 """Implements the Database Node"""
 
+import sys
 import simplejson as json
 import re
 from functools import wraps
@@ -568,6 +569,24 @@ class DatabaseView(PGChildNodeView):
 )
 
 data['old_name'] = (rset['rows'][0])['name']
+
+# pg_database is cluster level table (with encoding utf-8)
+# which is common to all databases under that cluster.
+# So if connection of database with encoding other than utf-8 is
+# used to query data from pg_database then manually decode
+# database name to get correct one.
+
+if self.conn.py_encoding != 'utf_8':
+if sys.version_info < (3,):
+data['old_name'] = data['old_name']\
+.decode('utf-8')\
+.encode(self.conn.py_encoding)\
+.decode('utf-8')
+else:
+data['old_name'] = bytes(
+data['old_name'], self.conn.py_encoding
+).decode('utf-8')
+
 if 'name' not in data:
 data['name'] = data['old_name']
 
diff --git a/web/pgadmin/browser/utils.py b/web/pgadmin/browser/utils.py
index 0dc2d01..2224720 100644
--- a/web/pgadmin/browser/utils.py
+++ b/web/pgadmin/browser/utils.py
@@ -11,6 +11,7 @@
 
 from abc import abstractmethod
 
+import sys
 import flask
 from flask import render_template, current_app
 from flask_babel import gettext
@@ -368,7 +369,24 @@ class PGChildNodeView(NodeView):
 current_app.logger.error(result)
 
 for row in result['rows']:
+
+# pg_database is cluster level table (with encoding utf-8)
+# which is common to all databases under that cluster.
+# So if connection of database with encoding other than utf-8 is
+# used to query data from pg_database then manually decode
+# dependencies name to get correct one.
 ref_name = row['refname']
+if conn.py_encoding != 'utf_8':
+if sys.version_info < (3,):
+ref_name = ref_name\
+.decode('utf-8')\
+.encode(conn.py_encoding)\
+.decode('utf-8')
+else:
+ref_name = bytes(
+ref_name, conn.py_encoding
+).decode('utf-8')
+
 dep_str = row['deptype']
 dep_type = ''
 
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index 4cafeb2..b442846 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -26,7 +26,7 @@ from flask import g, current_app, session
 from flask_babel import gettext
 from flask_security import current_user
 from pgadmin.utils.crypto import decrypt
-from psycopg2.extensions import adapt
+from psycopg2.extensions import adapt, encodings
 
 import config
 from pgadmin.model import Server, User
@@ -74,6 +74,7 @@ psycopg2.extensions.register_type(
 'NUMERIC_RANGE_TEXT', psycopg2.STRING)
 )
 
+
 def register_string_typecasters(connection):
 """
 Casts various types to string, resolving issues with out of
@@ -94,6 +95,30 @@ def register_string_typecasters(connection):
 new_type = psycopg2.extensions.new_type(oids, 'RETURN_STRING', return_as_string)
 psycopg2.extensions.register_type(new_type)
 
+# In python3 when database encoding is other than utf-8 and client encoding
+# is set to UNICODE then we need to map data from database encoding
+# to utf-8.
+# This is required because when client encoding is set to UNICODE then
+# psycopg assumes database encoding utf-8 and not the actual encoding.
+# Not sure whether it's bug or feature in psycopg for python3.
+
+if sys.version_info >= (3,) and connection.encoding != 'UTF8':
+def return_as_unicode(value, cursor):
+if value is None:
+return None
+# Treat value

Re: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2017-01-19 Thread Harshal Dhumal
Hi,

Pls find updated patch (V7) for direct file navigation with below bug fixes.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jan 16, 2017 at 8:42 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Sat, Jan 14, 2017 at 2:27 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Pls updated patch for RM1911.
> >
> > 1. This includes fix for issue index out of range when user enters path
> of
> > folder without trailing slash (showed by Dave).
> > 2. To make this functionality compatible with save last used directory
> > feature.
>
> - The first test I ran gave the error seen in the attachment (running
> in server mode, clicking the Browse button on the backup dialogue).
>
Fixed.


>
> - I also noticed in reviewing the changes again, that you've got code
> in sqleditor/__init__.py to stop the user moving outside of the
> storage sandbox in server mode. That code should be part of the file
> manager - none of the modules using it should be doing that kind of
> check.
>
> Fixed.


> - If I do try to navigate outside of the sandbox, I get a nice error:
> "Error: Access Denied (/Users/dpage/.pgadmin)" for example, if I enter
> /../../. Whilst it's good to be informative, it's also a security
> leak. It should only tell me the path that the user sees, not the path
> as it actually is on the server - e.g.  "Error: Access Denied
> (/../../../)"
>
> Fixed.



> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


RM1911_V7_20_Jan.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Minor patch for subnode control clean up code [pgAdmin4]

2017-01-18 Thread Harshal Dhumal
Hi,

This patch includes following change:
Properly remove any event listeners added by subnode control.

-- 
*Harshal Dhumal*
*Software Engineer*

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


subnode_cleanup.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2017-01-14 Thread Harshal Dhumal
Hi,

Pls updated patch for RM1911.

1. This includes fix for issue index out of range when user enters path of
folder without trailing slash (showed by Dave).
2. To make this functionality compatible with save last used directory
feature.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jan 9, 2017 at 12:40 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Dave,
>
>
> Please find attached rebased patch.
>
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Sun, Jan 8, 2017 at 4:07 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Hi
>>
>> Can you rebase this please? It no longer applies :-(
>>
>>
>> On Wednesday, December 28, 2016, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi Dave,
>>> Here is updated (V4) patch.
>>>
>>> Changes: 1] Now can enter both type of slashes ( / and \ ) and all will
>>> get replaced with the platform standard.
>>> 2] Added unicode support.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Mon, Dec 19, 2016 at 5:16 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>
>>>> Hi
>>>>
>>>> On Fri, Dec 16, 2016 at 6:46 PM, Harshal Dhumal
>>>> <harshal.dhu...@enterprisedb.com> wrote:
>>>> > Hi Dave,
>>>> >
>>>> > Please find updated patch below for direct file navigation.
>>>> > I have covered all of above mentioned case.
>>>>
>>>> Still not there I'm afraid:
>>>>
>>>> - On Mac, if I type \Users\dpage, it changes it to /\Users\dpage and
>>>> then tells me it doesn't exist. Per the RM, either forward or back
>>>> slashes should be acceptable ("The path should accept either / or \ as
>>>> separators. Upon successful navigation to the path (after pressing
>>>> Return), the slashes should be replaced with the platform standard if
>>>> needed.")
>>>>
>>>> - Unicode handling seems to be completely broken - see the attached
>>>> screenshot.
>>>>
>>>> I haven't tested on Windows yet, and only in Desktop mode on Mac.
>>>> Please test on Windows and Mac or Linux with both Python 2 and 3, in
>>>> both Server and Desktop modes to ensure that the behaviour meets the
>>>> requirements of the ticket with Unicode and non-Unicode paths and
>>>> files before resubmitting.
>>>>
>>>> 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
>>
>>
>
>


RM1911_V6_14_Jan.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Fwd: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2017-01-08 Thread Harshal Dhumal
Hi Dave,


Please find attached rebased patch.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Sun, Jan 8, 2017 at 4:07 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> Can you rebase this please? It no longer applies :-(
>
>
> On Wednesday, December 28, 2016, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi Dave,
>> Here is updated (V4) patch.
>>
>> Changes: 1] Now can enter both type of slashes ( / and \ ) and all will
>> get replaced with the platform standard.
>> 2] Added unicode support.
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Mon, Dec 19, 2016 at 5:16 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Hi
>>>
>>> On Fri, Dec 16, 2016 at 6:46 PM, Harshal Dhumal
>>> <harshal.dhu...@enterprisedb.com> wrote:
>>> > Hi Dave,
>>> >
>>> > Please find updated patch below for direct file navigation.
>>> > I have covered all of above mentioned case.
>>>
>>> Still not there I'm afraid:
>>>
>>> - On Mac, if I type \Users\dpage, it changes it to /\Users\dpage and
>>> then tells me it doesn't exist. Per the RM, either forward or back
>>> slashes should be acceptable ("The path should accept either / or \ as
>>> separators. Upon successful navigation to the path (after pressing
>>> Return), the slashes should be replaced with the platform standard if
>>> needed.")
>>>
>>> - Unicode handling seems to be completely broken - see the attached
>>> screenshot.
>>>
>>> I haven't tested on Windows yet, and only in Desktop mode on Mac.
>>> Please test on Windows and Mac or Linux with both Python 2 and 3, in
>>> both Server and Desktop modes to ensure that the behaviour meets the
>>> requirements of the ticket with Unicode and non-Unicode paths and
>>> files before resubmitting.
>>>
>>> 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
>
>
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 7040f11..28ec225 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -16,6 +16,7 @@ import string
 import sys
 import time
 from sys import platform as _platform
+import config
 
 import simplejson as json
 from flask import render_template, Response, session, request as req, url_for
@@ -241,6 +242,7 @@ def delete_trans_id(trans_id):
 data={'status': True}
 )
 
+
 @blueprint.route("/save_last_dir/", methods=["POST"])
 @login_required
 def save_last_directory_visited(trans_id):
@@ -259,12 +261,12 @@ class Filemanager(object):
 {
 'Error': gettext('No permission to operate on \
   specified path.'),
-'Code': -1
+'Code': 0
 }
 )
 self.dir = get_storage_directory()
 
-if (self.dir is not None and isinstance(self.dir, list)):
+if self.dir is not None and isinstance(self.dir, list):
 self.dir = ""
 
 @staticmethod
@@ -312,25 +314,34 @@ class Filemanager(object):
 folders_only = False
 title = "Storage Manager"
 
-# get last visited directory, if not present then traverse in reverse order
-# to find closest parent directory
+# get last visited directory, if not present then traverse in reverse
+# order to find closest parent directory
 last_dir = blueprint.last_directory_visited.get()
 if storage_dir is None:
 if last_dir is None:
 last_dir = "/"
 else:
 if last_dir is not None:
-if len(last_dir) > 1 and last_dir.endswith('/'):
+if len(last_dir) > 1 and \
+(last_dir.endswith('/') or last_dir.endswith('\\')):
 last_dir = last_dir[:-1]
 while last_dir:
 if os.path.exists(storage_dir + last_dir):
-break;
-index =

Re: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2016-12-27 Thread Harshal Dhumal
Hi Dave,
Here is updated (V4) patch.

Changes: 1] Now can enter both type of slashes ( / and \ ) and all will get
replaced with the platform standard.
2] Added unicode support.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Dec 19, 2016 at 5:16 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Fri, Dec 16, 2016 at 6:46 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > Please find updated patch below for direct file navigation.
> > I have covered all of above mentioned case.
>
> Still not there I'm afraid:
>
> - On Mac, if I type \Users\dpage, it changes it to /\Users\dpage and
> then tells me it doesn't exist. Per the RM, either forward or back
> slashes should be acceptable ("The path should accept either / or \ as
> separators. Upon successful navigation to the path (after pressing
> Return), the slashes should be replaced with the platform standard if
> needed.")
>
> - Unicode handling seems to be completely broken - see the attached
> screenshot.
>
> I haven't tested on Windows yet, and only in Desktop mode on Mac.
> Please test on Windows and Mac or Linux with both Python 2 and 3, in
> both Server and Desktop modes to ensure that the behaviour meets the
> requirements of the ticket with Unicode and non-Unicode paths and
> files before resubmitting.
>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 4d8f2c51..6177b195 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -16,6 +16,7 @@ import string
 import sys
 import time
 from sys import platform as _platform
+import config
 
 import simplejson as json
 from flask import render_template, Response, session, request as req, url_for
@@ -246,12 +247,12 @@ class Filemanager(object):
 {
 'Error': gettext('No permission to operate on \
   specified path.'),
-'Code': -1
+'Code': 0
 }
 )
 self.dir = get_storage_directory()
 
-if (self.dir is not None and isinstance(self.dir, list)):
+if self.dir is not None and isinstance(self.dir, list):
 self.dir = ""
 
 @staticmethod
@@ -391,11 +392,11 @@ class Filemanager(object):
 bitmask >>= 1
 if (drive_name != '' and drive_name is not None and
 drive_name in drives):
-return "{0}{1}".format(drive_name, ':/')
+return u"{0}{1}".format(drive_name, ':')
 else:
 return drives  # return drives if no argument is passed
 except Exception:
-return ['C:/']
+return ['C:']
 else:
 return '/'
 
@@ -408,12 +409,24 @@ class Filemanager(object):
 path = unquote(path)
 if hasattr(str, 'decode'):
 path = unquote(path).encode('utf-8').decode('utf-8')
+
+try:
+Filemanager.check_access_permission(dir, path)
+except Exception as e:
+err_msg = "Error: {0}".format(str(e))
+files = {
+'Code': 0,
+'Error': err_msg
+}
+return files
+
 files = {}
-if (_platform == "win32" and path == '/') and dir is None:
+if (_platform == "win32" and (path == '/' or path == '\\'))\
+and dir is None:
 drives = Filemanager._get_drives()
 for drive in drives:
 protected = 0
-path = file_name = "{0}:/".format(drive)
+path = file_name = u"{0}:".format(drive)
 try:
 drive_size = getDriveSize(path)
 drive_size_in_units = sizeof_fmt(drive_size)
@@ -452,7 +465,7 @@ class Filemanager(object):
 system_path = os.path.join(os.path.join(orig_path, f))
 
 # continue if file/folder is hidden
-if (is_folder_hidden(system_path) or f.startswith('.')):
+if is_folder_hidden(system_path) or f.startswith('.'):
 continue
 
 if hasattr(str, 'decode'):
@@ -473,7 +486,7 @@ class Filemanager(object):
 if files_only == 'true':
 continue
 file_extension = str('dir')
-user_path = "{0}/".format(user_path)
+ 

Re: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2016-12-16 Thread Harshal Dhumal
Hi Dave,

Please find updated patch below for direct file navigation.
I have covered all of above mentioned case.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Nov 25, 2016 at 4:09 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Thu, Nov 24, 2016 at 10:25 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > Please find updated attached patch for RM1911 (V2)
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Mon, Nov 21, 2016 at 7:48 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Hi
> >>
> >> On Sat, Nov 19, 2016 at 5:57 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> > PFA for RM1911
> >> >
> >> > Feature added: Allow user add file/folder path directly in input
> field.
> >> > Other improvements like clean up after file manager is closed.
> >>
> >> I did a quick check on Mac, in server mode and immediately hit problems:
> >>
> >> - [Screenshot 1]: I typed in "/Foo2" to navigate into the Foo2
> >> directory. a) it didn't navigate as expected, and b) it gave me a very
> >> non-user friendly error message.
> >>
> > Fixed.
> >>
> >> - [Screenshot 2]: I typed in "foo2.sql". It added the leading /
> >> automatically, then gave the error dpagefoo2.sql does not exist.
> >>
> > Fixed.
> >>
> >> Then on Windows in desktop mode:
> >>
> >> - [Screenshot 3]: I typed in "C:\Users\dpage" (which does exist) and
> >> got the error shown.
> >>
> > Fixed.
> >>
> >> - [Screenshot 4]: I typed in "\\172.16.253.235\data" (which does
> >> exist) and got the error shown.
> >
> > Fixed.
>
> - If I type in a path and hit return, it's properly opened. If I hit
> the Refresh button, it reloads a different location - in my case, for
> /Users/dpage it alwoys goes back to /Users. Oddly, it doesn't do that
> in /usr/bin.
>
> - The issue above is also seen with /Test_Folder (when running in
> server mode). It refreshes back to /
>
> - If I navigate to /abc/123/, then upload a file called emails.txt, it
> gets saved as /abc/123emails.txt.
>
> - On Windows (in server mode), if I try to navigate to
> \\vmware-host\Shared Folders\dpage (which exists and is accessible
> from the machine/user), it changes the name to "/\\vmware-host\Shared
> Folders\dpage" and gives an error that "dpage" doesn't exist.
>
> - After many of these errors, the OK button is enabled, and clicking
> it gives an error: "Invalid mode ('rb') or filename"
>
> - On Windows (in desktop mode), I'm stuck in the root of the C drive.
> I cannot click the Up directory button to see the available drives.
>
> - On Windows (in desktop mode), if I type "C:\" into the location bar,
> it navigates to the folder, but changes the path to "C:\/"
>
> - On windows (in desktop mode), if I type "\\172.16.253.235\data" into
> the location bar, I get "'' file does not exist"
>
> Please test thoroughly on Windows and *nix, in both server and desktop
> mode before resubmitting.
>
> Thanks.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 4d8f2c5..0054010 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -16,6 +16,7 @@ import string
 import sys
 import time
 from sys import platform as _platform
+import config
 
 import simplejson as json
 from flask import render_template, Response, session, request as req, url_for
@@ -246,12 +247,12 @@ class Filemanager(object):
 {
 'Error': gettext('No permission to operate on \
   specified path.'),
-'Code': -1
+'Code': 0
 }
 )
 self.dir = get_storage_directory()
 
-if (self.dir is not None and isinstance(self.dir, list)):
+if self.dir is not None and isinstance(self.dir, list):
 self.dir = ""
 
 @staticmethod
@@ -391,11 +392,11 @@ class Filemanager(object):
 bitm

Re: [pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2016-11-24 Thread Harshal Dhumal
Hi Dave,

Please find updated attached patch for RM1911 (V2)

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Nov 21, 2016 at 7:48 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Sat, Nov 19, 2016 at 5:57 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA for RM1911
> >
> > Feature added: Allow user add file/folder path directly in input field.
> > Other improvements like clean up after file manager is closed.
>
> I did a quick check on Mac, in server mode and immediately hit problems:
>
> - [Screenshot 1]: I typed in "/Foo2" to navigate into the Foo2
> directory. a) it didn't navigate as expected, and b) it gave me a very
> non-user friendly error message.
>
> Fixed.

> - [Screenshot 2]: I typed in "foo2.sql". It added the leading /
> automatically, then gave the error dpagefoo2.sql does not exist.
>
> Fixed.

> Then on Windows in desktop mode:
>
> - [Screenshot 3]: I typed in "C:\Users\dpage" (which does exist) and
> got the error shown.
>
> Fixed.

> - [Screenshot 4]: I typed in "\\172.16.253.235\data" (which does
> exist) and got the error shown.
>
Fixed.

>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 4a8e709..74f37fc 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -15,6 +15,7 @@ import random
 import string
 import time
 from sys import platform as _platform
+import config
 
 import simplejson as json
 from flask import render_template, Response, session, request as req, url_for
@@ -244,12 +245,12 @@ class Filemanager(object):
 {
 'Error': gettext('No permission to operate on \
   specified path.'),
-'Code': -1
+'Code': 0
 }
 )
 self.dir = get_storage_directory()
 
-if (self.dir is not None and isinstance(self.dir, list)):
+if self.dir is not None and isinstance(self.dir, list):
 self.dir = ""
 
 @staticmethod
@@ -403,6 +404,20 @@ class Filemanager(object):
 It lists all file and folders within the given
 directory.
 """
+if dir is None:
+dir = ""
+try:
+Filemanager.check_access_permission(dir, path)
+except Exception as e:
+err_msg = "Error: {0}".format(str(e))
+files = {
+'Code': 0,
+'Error': err_msg
+}
+return files
+
+orig_path = "{0}{1}".format(dir, path)
+
 files = {}
 if (_platform == "win32" and path == '/') and dir is None:
 drives = Filemanager._get_drives()
@@ -428,9 +443,6 @@ class Filemanager(object):
 }
 return files
 
-if dir is None:
-dir = ""
-orig_path = "{0}{1}".format(dir, path)
 user_dir = path
 folders_only = trans_data['folders_only'] if 'folders_only' in \
  trans_data else ''
@@ -447,7 +459,7 @@ class Filemanager(object):
 system_path = os.path.join(os.path.join(orig_path, f))
 
 # continue if file/folder is hidden
-if (is_folder_hidden(system_path) or f.startswith('.')):
+if is_folder_hidden(system_path) or f.startswith('.'):
 continue
 
 user_path = os.path.join(os.path.join(user_dir, f))
@@ -494,10 +506,27 @@ class Filemanager(object):
 err_msg = "Error: {0}".format(e)
 files = {
 'Code': 0,
-'err_msg': err_msg
+'Error': err_msg
 }
 return files
 
+@staticmethod
+def check_access_permission(dir, path):
+if dir is None:
+dir = ""
+orig_path = "{0}{1}".format(dir, path)
+
+# This translates path with relative path notations like ./ and ../ to
+# absolute path.
+orig_path = os.path.abspath(orig_path)
+
+# Do not allow user to access outside his storage dir in server mode.
+if config.SERVER_MODE is True:
+if not orig_path.startswith(dir):
+raise Exception(
+gettext("Access denied ({})".format(orig_path)))
+return True
+
 def validate_request(self, capability):
 """

[pgadmin-hackers] Patch for RM1911 Direct file navigation [pgAdmin4] [Feature]

2016-11-19 Thread Harshal Dhumal
Hi,

PFA for RM1911

Feature added: Allow user add file/folder path directly in input field.
Other improvements like clean up after file manager is closed.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/misc/file_manager/__init__.py b/web/pgadmin/misc/file_manager/__init__.py
index 4a8e709..a64ee4a 100644
--- a/web/pgadmin/misc/file_manager/__init__.py
+++ b/web/pgadmin/misc/file_manager/__init__.py
@@ -15,6 +15,7 @@ import random
 import string
 import time
 from sys import platform as _platform
+import config
 
 import simplejson as json
 from flask import render_template, Response, session, request as req, url_for
@@ -403,6 +404,20 @@ class Filemanager(object):
 It lists all file and folders within the given
 directory.
 """
+if dir is None:
+dir = ""
+try:
+Filemanager.check_access_permission(dir, path)
+except Exception as e:
+err_msg = "Error: {0}".format(str(e))
+files = {
+'Code': -1,
+'err_msg': err_msg
+}
+return files
+
+orig_path = "{0}{1}".format(dir, path)
+
 files = {}
 if (_platform == "win32" and path == '/') and dir is None:
 drives = Filemanager._get_drives()
@@ -428,9 +443,6 @@ class Filemanager(object):
 }
 return files
 
-if dir is None:
-dir = ""
-orig_path = "{0}{1}".format(dir, path)
 user_dir = path
 folders_only = trans_data['folders_only'] if 'folders_only' in \
  trans_data else ''
@@ -447,7 +459,7 @@ class Filemanager(object):
 system_path = os.path.join(os.path.join(orig_path, f))
 
 # continue if file/folder is hidden
-if (is_folder_hidden(system_path) or f.startswith('.')):
+if is_folder_hidden(system_path) or f.startswith('.'):
 continue
 
 user_path = os.path.join(os.path.join(user_dir, f))
@@ -498,6 +510,23 @@ class Filemanager(object):
 }
 return files
 
+@staticmethod
+def check_access_permission(dir, path):
+if dir is None:
+dir = ""
+orig_path = "{0}{1}".format(dir, path)
+
+# This translates path with relative path notations like ./ and ../ to
+# absolute path.
+orig_path = os.path.abspath(orig_path)
+
+# Do not allow user to access outside his storage dir in server mode.
+if config.SERVER_MODE is True:
+if not orig_path.startswith(dir):
+raise Exception(
+gettext("Access denied ({})".format(orig_path)))
+return True
+
 def validate_request(self, capability):
 """
 It validates the capability with the capabilities
@@ -515,14 +544,37 @@ class Filemanager(object):
 path = unquote(path)
 if self.dir is None:
 self.dir = ""
+
+try:
+Filemanager.check_access_permission(self.dir, path)
+except Exception as e:
+thefile = {
+'Filename': split_path(path)[-1],
+'FileType': '',
+'Path': path,
+'Error': gettext("Error: {0}".format(str(e))),
+'Code': -1,
+'Info': '',
+'Properties': {
+'Date Created': '',
+'Date Modified': '',
+'Width': '',
+'Height': '',
+'Size': ''
+}
+}
+return thefile
+
 orig_path = "{0}{1}".format(self.dir, path)
+
 user_dir = path
 thefile = {
 'Filename': split_path(orig_path)[-1],
-'File Type': '',
+'FileType': '',
 'Path': user_dir,
 'Error': '',
 'Code': 0,
+'Info': '',
 'Properties': {
 'Date Created': '',
 'Date Modified': '',
@@ -533,13 +585,18 @@ class Filemanager(object):
 }
 
 if not path_exists(orig_path):
-thefile['Error'] = gettext('File does not exist.')
-return (encode_json(thefile), None, 'application/json')
-
-if split_path(user_dir)[-1] == '/':
-thefile['File Type'] = 'Directory'
+thefile['Error'] = gettext("'{}' file does not exist.".format(
+split_path(orig_path)[-1]))
+thefile['Code'] = -1
+return thefile
+
+if split_path(user_dir)[-1] == '/'\
+or os.path.isfile(orig_path) is False:
+thefile['

Re: [pgadmin-hackers] PGAdmin 4 Bug report

2016-11-08 Thread Harshal Dhumal
Hi,

This is known issue and already reported here
https://redmine.postgresql.org/issues/1797
This will be taken care in future release. Until this issue gets fixed you
can use normal english characters in directory name/path.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Nov 8, 2016 at 2:30 PM, Adrian Beauchamp <adrian.beauch...@crown.com
> wrote:

> Dear Team,
>
>
>
> please excuse me if this is not the correct way to report an issue.
>
> If this is the wrong channel, if someone could point me towards to correct
> way to report an issue that would be fine.
>
>
>
> I just installed PGAdmin 4 vers 1.1 on 10.08 from an install file
> downloaded yesterday  to give it a try out.
>
>
>
>
>
> I have a German language edition of Windows 8
>
>
>
>
>
> My issue is when I try to open an SQL file from within the query tool.
>
> When I click through to my home directory I get the following error:
>
>
>
>
>
> The directory is C:\Users\abeaucha
>
>
>
> If I copy my SQL into a different directory , eg under C:\SQL\... I can
> get to them OK, but it should be possible to store my files in my users
> home directory ( especially for compliance to company policy )
>
>
>
> Interestingly, I tried to create a directory c:\Users\test I can click
> through here without an error.
>
>
>
> Unfortunately, I am not a Python person, so I don’t really know how to do
> any more troubleshooting on this.
>
> I would be happy to provide more info on request.
>
>
>
> The new interface looks very nice, thank you for your efforts.
>
>
>
> Kind regards
>
> Adrian Beauchamp | Database Administrator
>
> Email:adrian.beauch...@crown.com
>
> Crown Gabelstapler GmbH & Co. | Feldkirchen – Germany
>
> www.crown.com/de
>
>
>
>
>
>
> Registergericht Regensburg HR A6730, Sitz Roding
> Komplementär: Crown Gabelstapler Verwaltungs GmbH
> Registergericht Regensburg HRB 8854, Sitz Roding
> Geschäftsführer der Komplementärgesellschaft: Kenneth Dufford
>


Re: [pgadmin-hackers] Patch for pgagent RM1878 [pgAgent]

2016-10-24 Thread Harshal Dhumal
Hi Dave,


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Oct 24, 2016 at 1:34 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Mon, Oct 24, 2016 at 7:27 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > I mean reverse engineered sql tab. Currently it's not implemented for
> both
> > pgagent schedule and jobs.
>
> Yes it is - that's the change I made to your patch: "one change to
> *enable* the SQL tabs everywhere".


Ok.

>
> > I have created Rm for that  RM1891
>
> Please confirm it's working now, and update the ticket accordingly. It
> won't hurt to have that listed as a separate change for 1.1.
>

SQL tab in create and update properties mode works properly also Fahar
tested and closed same issue.

The ticket 1891 is for reverse engineered SQL. Currently it's giving 404
error when reverse engineered SQL tab is selected for schedule or job. I
have also attached screen shot in RM1891
<https://redmine.postgresql.org/issues/1891>.

In pgadmin3 I can't see reverse engineered SQL for both schedule or jobs.
So I'm confused whether we need to add implementation of same in pgAdmin4
or disabled reverse engineered SQL.


> > On Fri, Oct 21, 2016 at 8:30 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Thanks - applied, with one change to *enable* the SQL tabs everywhere.
> >>
> >> On Fri, Oct 21, 2016 at 2:41 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> > PFA updated patch for RM1878
> >> >
> >> > Issues fixed:
> >> >
> >> > 1. ProgrammingError: can't adapt type 'Undefined' for schedule
> >> > 2. Fixed malformed array literal issue raised by postgres while
> creating
> >> > schedule
> >> > 3. Fixed update of schedule.
> >> > 4. Fixed update of step.
> >> > 5. disabled sql tab (create sql tab) for step.
> >> >
> >> > --
> >> > Harshal Dhumal
> >> > Software Engineer
> >> >
> >> > EnterpriseDB India: http://www.enterprisedb.com
> >> > The Enterprise PostgreSQL Company
> >> >
> >> > On Fri, Oct 21, 2016 at 4:11 PM, Harshal Dhumal
> >> > <harshal.dhu...@enterprisedb.com> wrote:
> >> >>
> >> >> Hi,
> >> >>
> >> >> Please ignore this patch as I haven't fixed same issue for schedule.
> >> >> Also
> >> >> there is issue "malformed array literal" when we try to save
> schedule.
> >> >>
> >> >> I'll be sending updated patch.
> >> >>
> >> >> Thanks Harshal,
> >> >>
> >> >> --
> >> >> Harshal Dhumal
> >> >> Software Engineer
> >> >>
> >> >> EnterpriseDB India: http://www.enterprisedb.com
> >> >> The Enterprise PostgreSQL Company
> >> >>
> >> >> On Fri, Oct 21, 2016 at 2:51 PM, Harshal Dhumal
> >> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> >>>
> >> >>> Hi,
> >> >>>
> >> >>> PFA attached patch for pgagent issue RM1878
> >> >>>
> >> >>> issue fixed: ProgrammingError: can't adapt type 'Undefined'
> >> >>>
> >> >>> --
> >> >>> Harshal Dhumal
> >> >>> Software Engineer
> >> >>>
> >> >>> EnterpriseDB India: http://www.enterprisedb.com
> >> >>> The Enterprise PostgreSQL Company
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> > --
> >> > Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org
> )
> >> > To make changes to your subscription:
> >> > http://www.postgresql.org/mailpref/pgadmin-hackers
> >> >
> >>
> >>
> >>
> >> --
> >> 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
>


Re: [pgadmin-hackers] Patch for pgagent RM1878 [pgAgent]

2016-10-24 Thread Harshal Dhumal
Hi Dave,

I mean reverse engineered sql tab. Currently it's not implemented for both
pgagent schedule and jobs.

I have created Rm for that  RM1891
<https://redmine.postgresql.org/issues/1891>

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Oct 21, 2016 at 8:30 PM, Dave Page <dp...@pgadmin.org> wrote:

> Thanks - applied, with one change to *enable* the SQL tabs everywhere.
>
> On Fri, Oct 21, 2016 at 2:41 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA updated patch for RM1878
> >
> > Issues fixed:
> >
> > 1. ProgrammingError: can't adapt type 'Undefined' for schedule
> > 2. Fixed malformed array literal issue raised by postgres while creating
> > schedule
> > 3. Fixed update of schedule.
> > 4. Fixed update of step.
> > 5. disabled sql tab (create sql tab) for step.
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Fri, Oct 21, 2016 at 4:11 PM, Harshal Dhumal
> > <harshal.dhu...@enterprisedb.com> wrote:
> >>
> >> Hi,
> >>
> >> Please ignore this patch as I haven't fixed same issue for schedule.
> Also
> >> there is issue "malformed array literal" when we try to save schedule.
> >>
> >> I'll be sending updated patch.
> >>
> >> Thanks Harshal,
> >>
> >> --
> >> Harshal Dhumal
> >> Software Engineer
> >>
> >> EnterpriseDB India: http://www.enterprisedb.com
> >> The Enterprise PostgreSQL Company
> >>
> >> On Fri, Oct 21, 2016 at 2:51 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >>>
> >>> Hi,
> >>>
> >>> PFA attached patch for pgagent issue RM1878
> >>>
> >>> issue fixed: ProgrammingError: can't adapt type 'Undefined'
> >>>
> >>> --
> >>> Harshal Dhumal
> >>> Software Engineer
> >>>
> >>> EnterpriseDB India: http://www.enterprisedb.com
> >>> The Enterprise PostgreSQL Company
> >>
> >>
> >
> >
> >
> > --
> > Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgadmin-hackers
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] patch for RM1875 exclusion constraint support for pg-9.6 [pgAdmin4]

2016-10-21 Thread Harshal Dhumal
Hi,

PFA patch for RM1875.

Issue fixed:
1. Exclusion constraint added support for pg-9.6
2. Fixed index out of list (python error) when Exclusion constraint is
created without name.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index b8af0cd..9868280 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -290,7 +290,11 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 self.template_path = 'table/sql/9.1_plus'
 
 # Template for Column ,check constraint and exclusion constraint node
-if ver >= 90200:
+if ver >= 90600:
+self.column_template_path = 'column/sql/9.2_plus'
+self.check_constraint_template_path = 'check_constraint/sql/9.2_plus'
+self.exclusion_constraint_template_path = 'exclusion_constraint/sql/9.6_plus'
+elif ver >= 90200:
 self.column_template_path = 'column/sql/9.2_plus'
 self.check_constraint_template_path = 'check_constraint/sql/9.2_plus'
 self.exclusion_constraint_template_path = 'exclusion_constraint/sql/9.2_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index 6bc0bb0..495064c 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -217,7 +217,9 @@ class ExclusionConstraintView(PGChildNodeView):
 self.conn = self.manager.connection(did=kwargs['did'])
 
 ver = self.manager.version
-if ver >= 90200:
+if ver >= 90600:
+self.template_path = 'exclusion_constraint/sql/9.6_plus'
+elif ver >= 90200:
 self.template_path = 'exclusion_constraint/sql/9.2_plus'
 elif ver >= 90100:
 self.template_path = 'exclusion_constraint/sql/9.1_plus'
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
index 96c181e..9250d9f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/templates/exclusion_constraint/js/exclusion_constraint.js
@@ -700,8 +700,14 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
   if (column_collection.length > 0 && current_am != previous_am) {
 var msg = '{{ _('Changing access method will clear columns collection') }}';
 Alertify.confirm(msg, function (e) {
-// User clicks Ok, lets clear collection
-column_collection.reset();
+// User clicks Ok, lets clear collection.
+column_collection.each(function(m) {
+  /*
+   * Our datamodel do not support collection reset method.
+   * So remove model one by one.
+   */
+  column_collection.remove(m);
+});
 setTimeout(function() {
   column_collection.trigger('pgadmin:columns:updated', column_collection);
 }, 10);
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql
index abe636a..0fc1fa8 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/exclusion_constraint/sql/9.1_plus/get_oid_with_transaction.sql
@@ -2,5 +2,5 @@ SELECT ct.oid,
 ct.conname as name,
 NOT convalidated as convalidated
 FROM pg_constraint ct
-WHERE contype='f' AND
+WHERE contype='x' 

Re: [pgadmin-hackers] Patch for pgagent RM1878 [pgAgent]

2016-10-21 Thread Harshal Dhumal
Hi,

PFA updated patch for RM1878

Issues fixed:

1. ProgrammingError: can't adapt type 'Undefined' for schedule
2. Fixed malformed array literal issue raised by postgres while creating
schedule
3. Fixed update of schedule.
4. Fixed update of step.
5. disabled sql tab (create sql tab) for step.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Oct 21, 2016 at 4:11 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> Please ignore this patch as I haven't fixed same issue for schedule. Also
> there is issue "malformed array literal" when we try to save schedule.
>
> I'll be sending updated patch.
>
> Thanks Harshal,
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Fri, Oct 21, 2016 at 2:51 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA attached patch for pgagent issue RM1878
>>
>> issue fixed: ProgrammingError: can't adapt type 'Undefined'
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
index 24ea1ba..4dd82e8 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/schedules/__init__.py
@@ -219,8 +219,8 @@ class JobScheduleView(PGChildNodeView):
 res = []
 sql = render_template(
 "/".join([self.template_path, 'nodes.sql']),
-jscid = jscid,
-jid = jid
+jscid=jscid,
+jid=jid
 )
 
 status, result = self.conn.execute_2darray(sql)
@@ -298,13 +298,22 @@ class JobScheduleView(PGChildNodeView):
 jid: Job ID
 """
 data = {}
-for k, v in request.args.items():
-try:
-data[k] = json.loads(
-v.decode('utf-8') if hasattr(v, 'decode') else v
-)
-except ValueError:
-data[k] = v
+if request.args:
+for k, v in request.args.items():
+try:
+data[k] = json.loads(
+v.decode('utf-8') if hasattr(v, 'decode') else v
+)
+except ValueError:
+data[k] = v
+else:
+data = json.loads(request.data.decode())
+# convert python list literal to postgres array literal.
+data['jscminutes'] = data['jscminutes'].replace("[", "{").replace("]", "}")
+data['jschours'] = data['jschours'].replace("[", "{").replace("]", "}")
+data['jscweekdays'] = data['jscweekdays'].replace("[", "{").replace("]", "}")
+data['jscmonthdays'] = data['jscmonthdays'].replace("[", "{").replace("]", "}")
+data['jscmonths'] = data['jscmonths'].replace("[", "{").replace("]", "}")
 
 sql = render_template(
 "/".join([self.template_path, 'create.sql']),
@@ -327,8 +336,8 @@ class JobScheduleView(PGChildNodeView):
 self.conn.execute_void('END')
 sql = render_template(
 "/".join([self.template_path, 'nodes.sql']),
-jscid = res,
-jid = jid
+jscid=res,
+jid=jid
 )
 status, res = self.conn.execute_2darray(sql)
 
@@ -357,17 +366,36 @@ class JobScheduleView(PGChildNodeView):
 jscid: JobSchedule ID
 """
 data = {}
-for k, v in request.args.items():
-try:
-data[k] = json.loads(
-v.decode('utf-8') if hasattr(v, 'decode') else v
-)
-except ValueError:
-data[k] = v
+if request.args:
+for k, v in request.args.items():
+try:
+data[k] = json.loads(
+v.decode('utf-8') if hasattr(v, 'decode') else v
+)
+except ValueError:
+data[k] = v
+else:
+data = json.loads(request.data.decode())
+# convert python list literal to postgres array literal.
+if 'jscminutes' in data:
+data['jscminutes'] = data['jscminutes'].replace("[", "{").repla

Re: [pgadmin-hackers] Patch for pgagent RM1878 [pgAgent]

2016-10-21 Thread Harshal Dhumal
Hi,

Please ignore this patch as I haven't fixed same issue for schedule. Also
there is issue "malformed array literal" when we try to save schedule.

I'll be sending updated patch.

Thanks Harshal,

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Oct 21, 2016 at 2:51 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA attached patch for pgagent issue RM1878
>
> issue fixed: ProgrammingError: can't adapt type 'Undefined'
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] Patch for pgagent RM1878 [pgAgent]

2016-10-21 Thread Harshal Dhumal
Hi,

PFA attached patch for pgagent issue RM1878

issue fixed: ProgrammingError: can't adapt type 'Undefined'

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
index ccded7a..4def636 100644
--- a/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/pgagent/steps/__init__.py
@@ -232,8 +232,8 @@ SELECT EXISTS(
 res = []
 sql = render_template(
 "/".join([self.template_path, 'nodes.sql']),
-jstid = jstid,
-jid = jid
+jstid=jstid,
+jid=jid
 )
 
 status, result = self.conn.execute_2darray(sql)
@@ -315,13 +315,16 @@ SELECT EXISTS(
 jid: Job ID
 """
 data = {}
-for k, v in request.args.items():
-try:
-data[k] = json.loads(
-v.decode('utf-8') if hasattr(v, 'decode') else v
-)
-except ValueError:
-data[k] = v
+if request.args:
+for k, v in request.args.items():
+try:
+data[k] = json.loads(
+v.decode('utf-8') if hasattr(v, 'decode') else v
+)
+except ValueError:
+data[k] = v
+else:
+data = json.loads(request.data.decode())
 
 sql = render_template(
 "/".join([self.template_path, 'create.sql']),
@@ -337,8 +340,8 @@ SELECT EXISTS(
 
 sql = render_template(
 "/".join([self.template_path, 'nodes.sql']),
-jstid = res,
-jid = jid
+jstid=res,
+jid=jid
 )
 status, res = self.conn.execute_2darray(sql)
 
@@ -417,8 +420,8 @@ SELECT EXISTS(
 
 sql = render_template(
 "/".join([self.template_path, 'nodes.sql']),
-jstid = jstid,
-jid = jid
+jstid=jstid,
+jid=jid
 )
 status, res = self.conn.execute_2darray(sql)
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] patch for RM1863 [pgadmin4]

2016-10-20 Thread Harshal Dhumal
Hi,

PFA patch for RM1863.

Issue fixed: Correctly interpret composite data type for columns while
generating sql.
also minor UI improvement in foreign key column tab

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index daa6ef0..b8af0cd 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -275,6 +275,7 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 self.manager = driver.connection_manager(kwargs['sid'])
 self.conn = self.manager.connection(did=kwargs['did'])
 self.qtIdent = driver.qtIdent
+self.qtTypeIdent = driver.qtTypeIdent
 # We need datlastsysoid to check if current table is system table
 self.datlastsysoid = self.manager.db_info[
 did
@@ -681,7 +682,13 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 
 edit_types_list = list()
 # We will need present type in edit mode
-edit_types_list.append(present_type)
+
+if column['typnspname'] == "pg_catalog" or column['typnspname'] == "public":
+edit_types_list.append(present_type)
+else:
+t = self.qtTypeIdent(self.conn, column['typnspname'], present_type)
+edit_types_list.append(t)
+column['cltype'] = t
 
 if int(is_reference) == 0:
 SQL = render_template("/".join([self.column_template_path,
@@ -711,10 +718,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 if isArray:
 column['cltype'] += "[]"
 
-if column['typnspname'] != 'pg_catalog':
-column['cltype'] = self.qtIdent(self.conn, column['typnspname']) \
-   + '.' + column['cltype']
-
 if 'indkey' in column:
 # Current column
 attnum = str(column['attnum'])
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
index 33f585d..be6d121 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/__init__.py
@@ -199,6 +199,7 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
 )
 self.conn = self.manager.connection(did=kwargs['did'])
 self.qtIdent = driver.qtIdent
+self.qtTypeIdent = driver.qtTypeIdent
 
 # Set the template path for the SQL scripts
 if self.manager.version >= 90200:
@@ -417,7 +418,12 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
 
 edit_types_list = list()
 # We will need present type in edit mode
-edit_types_list.append(present_type)
+if data['typnspname'] == "pg_catalog" or data['typnspname'] == "public":
+edit_types_list.append(present_type)
+else:
+t = self.qtTypeIdent(self.conn, data['typnspname'], present_type)
+edit_types_list.append(t)
+data['cltype'] = t
 
 if int(is_reference) == 0:
 SQL = render_template("/".join([self.template_path,
@@ -447,10 +453,6 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
 if isArray:
 data['cltype'] += "[]"
 
-if data['typnspname'] != 'pg_catalog':
-data['cltype'] = self.qtIdent(self.conn, data['typnspname'])\
- + '.' + data['cltype']
-
 return data
 
 @check_precondition
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
index 9da61f9..4e50873 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
@@ -302,8 +302,8 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
 '   ',
 '<%-column_label%>',
 '   ',
-'   ',
-'   ',
+'   ',
+'   ',
 '  >',
   

[pgadmin-hackers] patch for RM1861 [pgAdmin4]

2016-10-20 Thread Harshal Dhumal
Hi,

PFA minor patch for RM1861.

Issue fixed: SQL not generated for exclusion constraint on table

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
index 3298a51..6bc0bb0 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/exclusion_constraint/__init__.py
@@ -804,7 +804,7 @@ class ExclusionConstraintView(PGChildNodeView):
 sql = render_template("/".join([self.template_path, 'create.sql']),
   data=data, conn=self.conn)
 
-return sql
+return sql, data['name'] if 'name' in data else old_data['name']
 
 @check_precondition
 def sql(self, gid, sid, did, scid, tid, exid=None):

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Patch for RM1531 and other improvements related to same issue [pgAdmin4]

2016-10-08 Thread Harshal Dhumal
Hi,

PFA patch for RM 1531.

Changes: 1. Fixed update privileges for views and materialized views.
2. Apart from this fixed wrong sql for privilege update.
3. Fixed: Error message was not got cleared even after removing entry with
error on privilege tab.



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
index 3c14b43..1063c4e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py
@@ -21,7 +21,8 @@ from pgadmin.browser.utils import PGChildNodeView
 from pgadmin.utils.ajax import make_json_response, internal_server_error, \
 make_response as ajax_response, bad_request
 from pgadmin.utils.driver import get_driver
-
+from pgadmin.browser.server_groups.servers.utils import parse_priv_from_db,\
+parse_priv_to_db
 from config import PG_DEFAULT_DRIVER
 from pgadmin.utils.ajax import gone
 
@@ -230,7 +231,7 @@ class ViewNode(PGChildNodeView, VacuumSettings):
   - This function is used to return modified SQL for the selected view
 node.
 
-* get_sql(data, scid)
+* getSQL(data, scid)
   - This function will generate sql from model data
 
 * sql(gid, sid, did, scid):
@@ -396,33 +397,6 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 status=200
 )
 
-def parse_views_privileges(self, db_privileges):
-"""
-This function forms a separate list of grantable
-and non grantable privileges.
-"""
-acl = {'grantor': db_privileges['grantor'],
-   'grantee': db_privileges['grantee'],
-   'privileges': []
-   }
-
-privileges = []
-for idx, priv in enumerate(db_privileges['privileges']):
-if db_privileges['grantable'][idx]:
-privileges.append({"privilege_type": priv,
-   "privilege": True,
-   "with_grant": True
-   })
-else:
-privileges.append({"privilege_type": priv,
-   "privilege": True,
-   "with_grant": False
-   })
-
-acl['privileges'] = privileges
-
-return acl
-
 @check_precondition
 def properties(self, gid, sid, did, scid, vid):
 """
@@ -446,11 +420,8 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 return internal_server_error(errormsg=res)
 
 for row in dataclres['rows']:
-priv = self.parse_views_privileges(row)
-if row['deftype'] in res['rows'][0]:
-res['rows'][0][row['deftype']].append(priv)
-else:
-res['rows'][0][row['deftype']] = [priv]
+priv = parse_priv_from_db(row)
+res['rows'][0].setdefault(row['deftype'], []).append(priv)
 
 result = res['rows'][0]
 
@@ -678,49 +649,6 @@ class ViewNode(PGChildNodeView, VacuumSettings):
 status=200
 )
 
-@staticmethod
-def parse_privileges(str_privileges, object_type='VIEW'):
-"""Parse Privileges."""
-db_privileges = {
-'a': 'INSERT',
-'r': 'SELECT',
-'w': 'UPDATE',
-'d': 'DELETE',
-'D': 'TRUNCATE',
-'x': 'REFERENCES',
-'t': 'TRIGGER'
-}
-privileges = []
-for priv in str_privileges:
-priv_with_grant = []
-priv_without_grant = []
-for privilege in priv['privileges']:
-if privilege['with_grant']:
-priv_with_grant.append(
-db_privileges[privilege['privilege_type']])
-elif privilege['privilege']:
-priv_without_grant.append(
-db_privileges[privilege['privilege_type']])
-
-# If we have all acl then just return all
-if len(priv_with_grant) == len(db_privileges):
-priv_with_grant = ['ALL']
-if len(priv_without_grant) == len(db_privileges):
-priv_without_grant = ['ALL']
-
-# Server Level validation
-if 'grantee' in priv:
-privileges.append(
-{
-'grantee': priv['grantee'] if 'grantee' in priv else '',
-'with_grant': priv_with_grant,
-'without_grant': priv_without_grant
-}
-

Re: [pgadmin-hackers] Patch for RM1720 [pgadmin4]

2016-09-22 Thread Harshal Dhumal
Hi,

Please find attached updated patch for RM1720.

Also test this patch with updated test suite patch which Navnath would be
sending.



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Sep 21, 2016 at 8:39 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Wed, Sep 21, 2016 at 4:02 PM, Navnath Gadakh
> <navnath.gad...@enterprisedb.com> wrote:
> > Hi Dave,
> > Can you please run testsuite for server or database node only, as
> > there are some code modifications are remaining on the rest of the nodes.
> > Currently i don't have a machine to look into issue, will check it
> tomorrow.
>
> OK, here's the result:
>
> (pgadmin4)piranha:web dpage$ python regression/runtests.py --pkg
> browser.server_groups.servers.databases
> pgAdmin 4 - Application Initialisation
> ==
>
>
> The configuration database - '/Users/dpage/.pgadmin/test_pgadmin4.db'
> does not exist.
> Entering initial setup mode...
> NOTE: Configuring authentication for SERVER mode.
>
>
> The configuration database has been created at
> /Users/dpage/.pgadmin/test_pgadmin4.db
>
> =Running the test cases for 'Regression - PG 9.4'=
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_add.DatabaseAddTestCase)
> This function will add database under 1st server of tree node. (Check
> Databases Node URL) ... ok
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_delete.DatabaseDeleteTestCase)
> This function will delete the database. (Check Databases Node URL) ... ok
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_get.DatabasesGetTestCase)
> This function will fetch added database. (Check Databases Node URL) ... ok
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_put.DatabasesUpdateTestCase)
> This function will update the comments field of database. (Check
> Databases Node) ... ok
>
> --
> Ran 4 tests in 1.310s
>
> OK
>
> =Running the test cases for 'Regression - PG 9.5'=
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_add.DatabaseAddTestCase)
> This function will add database under 1st server of tree node. (Check
> Databases Node URL) ... ok
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_delete.DatabaseDeleteTestCase)
> This function will delete the database. (Check Databases Node URL) ... FAIL
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_get.DatabasesGetTestCase)
> This function will fetch added database. (Check Databases Node URL) ...
> ERROR
> runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_put.DatabasesUpdateTestCase)
> This function will update the comments field of database. (Check
> Databases Node) ... ERROR
>
> ==
> ERROR: runTest (pgadmin.browser.server_groups.servers.databases.
> tests.test_db_get.DatabasesGetTestCase)
> This function will fetch added database. (Check Databases Node URL)
> --
> Traceback (most recent call last):
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/tests/test_db_get.py",
> line 33, in runTest
> self.db_id)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_
> groups/servers/databases/tests/utils.py",
> line 142, in verify_database
> follow_redirects=True)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/werkzeug/test.py",
> line 788, in post
> return self.open(*args, **kw)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/testing.py",
> line 113, in open
> follow_redirects=follow_redirects)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/werkzeug/test.py",
> line 751, in open
> response = self.run_wsgi_app(environ, buffered=buffered)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/werkzeug/test.py",
> line 668, in run_wsgi_app
> rv = run_wsgi_app(self.application, environ, buffered=buffered)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/werkzeug/test.py",
> line 871, in run_wsgi_app
> app_rv = app(environ, start_response)
>   File "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-
> packages/flask/app.py",

[pgadmin-hackers] Patch for RM1720 [pgadmin4]

2016-09-21 Thread Harshal Dhumal
Hi,

PFA patch for RM1720


Issue: In pgAdmin4 we use server id (sid, which is id of server table in
sqlite db) as key to keep track of server connection (server manger). But
sqlite reuses these ids and therefore pgadmin4 connection manager assigns
connection details of one database server to another in some cases.

To avoid this issue we now deleting server connection details (server
manger) when user drops server.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 0b6c6ca..627cc5f 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -24,6 +24,7 @@ from pgadmin.utils.menu import MenuItem
 import config
 from config import PG_DEFAULT_DRIVER
 from pgadmin.model import db, Server, ServerGroup, User
+from pgadmin.utils.driver import get_driver
 
 
 def has_any(data, keys):
@@ -64,7 +65,6 @@ class ServerModule(sg.ServerGroupPluginModule):
 servers = Server.query.filter_by(user_id=current_user.id,
  servergroup_id=gid)
 
-from pgadmin.utils.driver import get_driver
 driver = get_driver(PG_DEFAULT_DRIVER)
 
 for server in servers:
@@ -156,7 +156,6 @@ class ServerModule(sg.ServerGroupPluginModule):
 sub-modules at once.
 """
 if first_registration:
-from pgadmin.utils.driver import get_driver
 driver = get_driver(PG_DEFAULT_DRIVER, app)
 app.jinja_env.filters['qtLiteral'] = driver.qtLiteral
 app.jinja_env.filters['qtIdent'] = driver.qtIdent
@@ -224,7 +223,6 @@ class ServerNode(PGChildNodeView):
 servers = Server.query.filter_by(user_id=current_user.id,
  servergroup_id=gid)
 
-from pgadmin.utils.driver import get_driver
 driver = get_driver(PG_DEFAULT_DRIVER)
 
 for server in servers:
@@ -293,7 +291,6 @@ class ServerNode(PGChildNodeView):
 )
 )
 
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(server.id)
 conn = manager.connection()
 connected = conn.connected()
@@ -355,6 +352,8 @@ class ServerNode(PGChildNodeView):
 for s in servers:
 db.session.delete(s)
 db.session.commit()
+get_driver(PG_DEFAULT_DRIVER).delete_manager(sid)
+
 except Exception as e:
 current_app.logger.exception(e)
 return make_json_response(
@@ -405,7 +404,6 @@ class ServerNode(PGChildNodeView):
 request.data, encoding='utf-8'
 )
 
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection()
 connected = conn.connected()
@@ -473,7 +471,6 @@ class ServerNode(PGChildNodeView):
 ).first()
 res = []
 
-from pgadmin.utils.driver import get_driver
 driver = get_driver(PG_DEFAULT_DRIVER)
 
 for server in servers:
@@ -519,7 +516,6 @@ class ServerNode(PGChildNodeView):
 id=server.servergroup_id
 ).first()
 
-from pgadmin.utils.driver import get_driver
 driver = get_driver(PG_DEFAULT_DRIVER)
 
 manager = driver.connection_manager(sid)
@@ -594,7 +590,6 @@ class ServerNode(PGChildNodeView):
 user = None
 
 if 'connect_now' in data and data['connect_now']:
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(server.id)
 manager.update(server)
 conn = manager.connection()
@@ -663,7 +658,6 @@ class ServerNode(PGChildNodeView):
 return make_json_response(data='')
 
 def statistics(self, gid, sid):
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection()
 
@@ -717,7 +711,6 @@ class ServerNode(PGChildNodeView):
 
 def connect_status(self, gid, sid):
 """Check and return the connection status."""
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection()
 res = conn.connected()
@@ -769,7 +762,6 @@ class ServerNode(PGChildNodeView):
 save_password = False
 
 # Connect the Server
-from pgadmin.utils.driver import get_driver
 manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(sid)
 conn = manager.connection()
 
@@ -902,7 +894,6 @@ class ServerNode(PGChildNodeView):
  

Re: [pgadmin-hackers] Package node test cases [pgadmin4]

2016-09-01 Thread Harshal Dhumal
Ok, I'll do that once that work is completed.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Sep 1, 2016 at 3:57 PM, Dave Page <dp...@pgadmin.org> wrote:

> Per my earlier email to Priyanka, I'm not going to commit any more test
> cases until the existing issues are resolved and the enhanced summary and
> object cleanup work is complete, otherwise it's just taking too much time
> unnecessarily.
>
> Please re-test and resubmit this patch once that work is complete.
>
> Thanks.
>
> On Tue, Aug 30, 2016 at 12:05 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for package node test cases.
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] Package node test cases [pgadmin4]

2016-08-30 Thread Harshal Dhumal
Hi,

PFA patch for package node test cases.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/__init__.py
new file mode 100644
index 000..133b58a
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/__init__.py
@@ -0,0 +1,8 @@
+##
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_add.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_add.py
new file mode 100644
index 000..8099e86
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_add.py
@@ -0,0 +1,74 @@
+# #
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##
+
+from regression import test_utils as utils
+from pgadmin.utils.route import BaseTestGenerator
+from pgadmin.browser.server_groups.servers.tests import utils as server_utils
+from pgadmin.browser.server_groups.servers.databases.tests import utils as \
+database_utils
+from pgadmin.browser.server_groups.servers.databases.schemas.tests import \
+utils as schema_utils
+from . import utils as package_utils
+
+
+class PackageAddTestCase(BaseTestGenerator):
+""" This class will add new package under schema node. """
+
+scenarios = [
+# Fetching default URL for package node.
+('Fetch Package Node URL', dict(
+url='/browser/package/obj/'))
+]
+
+@classmethod
+def setUpClass(cls):
+"""
+This function perform the three tasks
+ 1. Add the test server
+ 2. Connect to server
+ 3. Add the databases
+ 4. Add the schemas
+
+:return: None
+"""
+
+# Firstly, add the server
+server_utils.add_server(cls.tester)
+# Connect to server
+cls.server_connect_response, cls.server_group, cls.server_ids = \
+server_utils.connect_server(cls.tester)
+if len(cls.server_connect_response) == 0:
+raise Exception("No Server(s) connected to add the database!!!")
+# Add database
+database_utils.add_database(cls.tester, cls.server_connect_response,
+cls.server_ids)
+# Add schemas
+schema_utils.add_schemas(cls.tester)
+
+def runTest(self):
+""" This function will add package under schema node. """
+
+package_utils.add_package(
+self.tester, self.server_connect_response, self.server_ids)
+
+@classmethod
+def tearDownClass(cls):
+"""
+This function deletes the added package, schemas, database,
+server and the 'parent_id.pkl' file which is created in setup()
+function.
+
+:return: None
+"""
+
+package_utils.delete_package(cls.tester)
+schema_utils.delete_schema(cls.tester)
+database_utils.delete_database(cls.tester)
+server_utils.delete_server(cls.tester)
+utils.delete_parent_id_file()
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_delete.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_delete.py
new file mode 100644
index 000..0d97991
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/tests/test_package_delete.py
@@ -0,0 +1,77 @@
+# #
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##
+
+from regression import test_utils as utils
+from pgadmin.utils.route import BaseTestGenerator
+from pgadmin.browser.server_groups.servers.tests import utils as server_utils
+from pgadmin.browser.server_groups.servers.databases.tests import utils as \
+database_utils
+from pgadmin.browser.server_groups.servers.databases.schemas.tests import \
+utils as schema_ut

Re: [pgadmin-hackers] [pgadmin4] Edb package support.

2016-08-22 Thread Harshal Dhumal
Hi Dave,

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Aug 22, 2016 at 5:45 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Mon, Aug 22, 2016 at 1:04 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> > PFA patch for wrong header and body were generated.
> >
> > Fixed the header and body sql parsing issue.
>
> Won't this break if I have a package called issues.foo or anything
> else that matches the ' is' or ' as'?
>
Yes, this causes issue. I have fixed it in updated patch.

Also fixed one more issue pointed by Khushboo, In some cases if we update
package header it drops package body. Ideally it should not drop body.



>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
index 1cdc2c0..8314046 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/__init__.py
@@ -8,7 +8,7 @@
 ##
 
 """Implements Package Node"""
-
+import re
 import simplejson as json
 from functools import wraps
 
@@ -662,16 +662,18 @@ class PackageView(PGChildNodeView):
 def get_inner(sql):
 if sql is None:
 return None
+start = 0
+start_position = re.search("\s+[is|as]+\s+", sql, flags=re.I)
 
-sql = sql.lower()
-start = sql.find('is')
-if start == -1:
-start = sql.find('as')
+if start_position:
+start = start_position.start() + 4
 
-end = max(sql.rfind('end;'), sql.rfind('end'))
+try:
+end_position = [i for i in re.finditer("end", sql, flags=re.I)][-1]
+end = end_position.start()
+except IndexError:
+return sql[start:].strip("\n")
 
-if start == -1:
-return sql[0: end].strip("\n")
-return sql[start+2: end].strip("\n")
+return sql[start:end].strip("\n")
 
 PackageView.register_node_view(blueprint)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
index 2c95c9c..fc0e056 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/edbfuncs/__init__.py
@@ -10,6 +10,7 @@
 """Implements Edb Functions/Edb Procedures Node."""
 
 import copy
+import re
 from functools import wraps
 
 import pgadmin.browser.server_groups.servers.databases.schemas.packages as packages
@@ -563,17 +564,19 @@ It may have been removed by another user or moved to another schema.
 def get_inner(sql):
 if sql is None:
 return None
+start = 0
+start_position = re.search("\s+[is|as]+\s+", sql, flags=re.I)
 
-sql = sql.lower()
-start = sql.find('is')
-if start == -1:
-start = sql.find('as')
+if start_position:
+start = start_position.start() + 4
 
-end = max(sql.rfind('end;'), sql.rfind('end'))
+try:
+end_position = [i for i in re.finditer("end", sql, flags=re.I)][-1]
+end = end_position.start()
+except IndexError:
+return sql[start:].strip("\n")
 
-if start == -1:
-return sql[0: end].strip("\n")
-return sql[start+2: end].strip("\n")
+return sql[start:end].strip("\n")
 
 EdbFuncView.register_node_view(blueprint)
 
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/ppas/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/ppas/9.1_plus/update.sql
index 2c1aed0..757bcef 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/ppas/9.1_plus/update.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/packages/templates/package/ppas/9.1_plus/update.sql
@@ -10,7 +10,16 @@ CREATE OR REPLACE PACKAGE {{ conn|qtIdent(data.schema,data.name) }}
 IS
 {{data.pkgheadsrc}}
 END {{ conn|qtIdent(data.name) }};
+
+CREATE OR REPLACE PACKAGE BODY {{ conn|qtIdent(data.schema,data.name) }}
+IS
+{% if data.pkgbodysrc %}
+{{data.pkgbodysrc}}
+{% else %}
+{{o_d

Re: [pgadmin-hackers] [pgadmin4] Edb package support.

2016-08-22 Thread Harshal Dhumal
Hi,
PFA patch for wrong header and body were generated.

Fixed the header and body sql parsing issue.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Aug 22, 2016 at 5:10 PM, Khushboo Vashi <
khushboo.va...@enterprisedb.com> wrote:

>
>
> On Mon, Aug 22, 2016 at 3:10 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA updated patch for packages
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Thu, Aug 18, 2016 at 12:34 PM, Khushboo Vashi <
>> khushboo.va...@enterprisedb.com> wrote:
>>
>>> Hi Harshal,
>>>
>>> Please see below review comments.
>>>
>>> 1. Please make one line space between every SQL block as per pgAdmin 4
>>> standard.
>>>
>> Fixed
>>
>>> 2. The RE SQL of package is not correct. The package name is displayed
>>> twice as shown below
>>>
>>> CREATE OR REPLACE PACKAGE enterprisedb.empinfo
>>>
>>> IS
>>>
>>> edb.empinfo is
>>>
>>> emp_name character varying(10);
>>>
>>> procedure get_name(p_empno numeric);
>>>
>>> function display_counter() return integer;
>>>
>>> END empinfo;
>>>
>>>
>>> Same applies for CREATE OR REPLACE PACKAGE BODY also.
>>>
>>>
>> Fixed
>>
>
> This issue is not fixed yet. I am able to reproduce it on PPAS 9.5
>
>
>> 3. The RE SQL of functions, procedures and variable are not correct.
>>> Currently it is showing the entire package body.
>>>
>>
>> Entire package body is stored as free text in single field in database.
>> There is no way that we can detect sql for particular function/procedure
>> and therefor I'm showing entire package body. (refer pgadmin3).
>> And for variables it's showing correct sql (refer pgadmin3)
>>
>> 4. The Create scripts are incorrect for the package and its sub-nodes.
>>> If I execute that script, it gives me an error.
>>>
>> Fixed for package. (fixed in point no. 2)
>> Create script is not applicable for functions, procedures, variables. I
>> have disable menu for package child nodes.
>>
>>
>>> 5. Not able to update the package header as well as body as in the edit
>>> window the script values are incorrect. So, at the end it will create the
>>> wrong SQL.
>>>
>>
>>  Fixed (fixed in point no. 2)
>>
>>> 6. Please check and change the comments for all the JS files if they are
>>> copied from another node. Ex: package.js is showing sequence node comments.
>>>
>>> Fixed.
>>
>>> 7. Please maintain 4 tab indentation for SQL templates
>>>
>>
>> Fixed
>>
>>>
>>> NOTE:  I have not repeated Dave's comments, so please incorporate those
>>> comments in this list.
>>>
>>>
>>> Thanks,
>>>
>>> Khushboo
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Thu, Aug 18, 2016 at 10:50 AM, Khushboo Vashi <
>>> khushboo.va...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Wed, Aug 17, 2016 at 4:35 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I did some quick testing, and found the following issues:
>>>>>
>>>>> - Package ACL is not shown in properties
>>>>>
>>>> Fxied
>>
>>
>>>
>>>>> - Package header and body are not shown in properties
>>>>>
>>>>
>> Fixed
>>
>>>
>>>>> - System package? is not shown in properties
>>>>>
>>>> Fixed
>>
>>
>>>
>>>>> - The header for the RE SQL on a package procedure should read:
>>>>>
>>>>> -- Package Procedure
>>>>>
>>>>> (not -- Package Function)
>>>>>
>>>>
>> Fixed
>>
>>
>>>
>>>>> Can you also have someone (Khushboo?) do a code review, if that hasn't
>>>>> happened already?
>>>>>
>>>>>
>>>> Sure, will do this.
>>>>
>>>>
>>>>> Thanks.
>>>

[pgadmin-hackers] patch for RM1538: show db default acls [pgadmin4]

2016-08-16 Thread Harshal Dhumal
Hi,

PFA patch for rm 1538 to show default database privileges in properties
mode.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
index 34c3e05..f9e75a2 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js
@@ -231,6 +231,18 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
   id: 'acl', label: '{{ _('Privileges') }}', type: 'text',
   group: '{{ _('Security') }}', mode: ['properties'], disabled: true
 },{
+  id: 'tblacl', label: '{{ _('Default TABLE Privileges') }}', type: 'text',
+  group: '{{ _('Security') }}', mode: ['properties'], disabled: true
+},{
+  id: 'seqacl', label: '{{ _('Default SEQUENCE Privileges') }}', type: 'text',
+  group: '{{ _('Security') }}', mode: ['properties'], disabled: true
+},{
+  id: 'funcacl', label: '{{ _('Default FUNCTION Privileges') }}', type: 'text',
+  group: '{{ _('Security') }}', mode: ['properties'], disabled: true
+},{
+  id: 'typeacl', label: '{{ _('Default TYPE Privileges') }}', type: 'text',
+  group: '{{ _('Security') }}', mode: ['properties'], disabled: true, min_version: 90200
+},{
   id: 'comments', label:'{{ _('Comment') }}',
   editable: false, type: 'multiline'
 },{
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
index d141adf..34969d6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/properties.sql
@@ -5,6 +5,9 @@ SELECT
 has_database_privilege(db.oid, 'CREATE') as cancreate,
 current_setting('default_tablespace') AS default_tablespace,
 descr.description as comments,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID) AS tblacl,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID) AS seqacl,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID) AS funcacl,
 array_to_string(datacl::text[], ', ') AS acl
 FROM pg_database db
 LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace=ta.OID
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
index 214ac7d..3c6a749 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/properties.sql
@@ -5,6 +5,10 @@ SELECT
 has_database_privilege(db.oid, 'CREATE') as cancreate,
 current_setting('default_tablespace') AS default_tablespace,
 descr.description as comments,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID) AS tblacl,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID) AS seqacl,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID) AS funcacl,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = 0::OID) AS typeacl,
 (SELECT array_agg(provider || '=' || label) FROM pg_shseclabel sl1 WHERE sl1.objoid=db.oid) AS seclabels,
 array_to_string(datacl::text[], ', ') AS acl
 FROM pg_database db
diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/properties.sql
index 214ac7d..3c6a749 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/properties.sql
@@ -5,6 +5,10 @@ SELECT
 has_database_privilege(db.oid, 'CREATE') as cancreate,
 current_setting('default_tablespace') AS default_tablespace,
 descr.description as comments,
+(SELECT array_to_string(defaclacl::text[], ', ') FROM

[pgadmin-hackers] [pgadmin4] fix for RM1417

2016-08-08 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1417.

Changes: Fixed privileges parsing issue while editing privileges of exiting
object.

Additional Note: This was general issue and was not related to runtime or
pg 9.6.



-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
index 70246f6..418122e 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/privilege.js
@@ -58,6 +58,7 @@
*  + privileges - Privileges for that role.
**/
   var PrivilegeRoleModel = pgNode.PrivilegeRoleModel = pgNode.Model.extend({
+idAttribute: 'grantee',
 defaults: {
   grantee: undefined,
   grantor: undefined,
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
index 356b808..4aa04ea 100644
--- a/web/pgadmin/browser/server_groups/servers/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -63,6 +63,24 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
 priv_with_grant = []
 priv_without_grant = []
 
+if isinstance(priv['privileges'], dict) and 'changed' in priv['privileges']:
+tmp = []
+for p in priv['privileges']['changed']:
+tmp_p = {'privilege_type': p['privilege_type'],
+ 'privilege': False,
+ 'with_grant': False}
+
+if 'with_grant' in p:
+tmp_p['privilege'] = True
+tmp_p['with_grant'] = p['with_grant']
+
+if 'privilege' in p:
+tmp_p['privilege'] = p['privilege']
+
+tmp.append(tmp_p)
+
+priv['privileges'] = tmp
+
 for privilege in priv['privileges']:
 
 if privilege['privilege_type'] not in db_privileges:

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] patch for RM1177 [pgadmin4]

2016-08-05 Thread Harshal Dhumal
Hi,

PFA patch for RM1177.

Issue fixed: Added a check to warn the user if the binary path is not set
before running external commands.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index 5ed582a..95528b0 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -692,7 +692,24 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
 pnlDialogHelp.focus();
 iframe.openURL(url);
   }
+},
+
+get_preference(module, preference_name) {
+  preference = null;
+  $.ajax({
+async: false,
+url: "{{ url_for('preferences.preferences') }}" +"/"+ module +"/"+ preference_name,
+success: function(res) {
+  preference = res;
+},
+error: function(xhr, status, error) {
+
+}
+  });
+
+  return preference;
 }
+
   });
 
   window.onbeforeunload = function(ev) {
diff --git a/web/pgadmin/preferences/__init__.py b/web/pgadmin/preferences/__init__.py
index 944542d..b282e43 100644
--- a/web/pgadmin/preferences/__init__.py
+++ b/web/pgadmin/preferences/__init__.py
@@ -82,18 +82,37 @@ def script():
 
 
 @blueprint.route("/preferences", methods=["GET"])
+@blueprint.route("/preferences//")
 @login_required
-def preferences():
-"""Fetch all the preferences of pgAdmin IV."""
+def preferences(module=None, preference=None):
+"""Fetch all/or requested preferences of pgAdmin IV."""
+
+if module is not None and preference is not None:
+try:
+m = Preferences.module(module, create=False)
+if m is None:
+return Response(status=404)
+
+p = m.preference(preference)
+if p is None:
+return Response(status=404)
+
+return ajax_response(
+response=p.to_json(),
+status=200
+)
+
+except Exception as e:
+return internal_server_error(errormsg=str(e))
 
 # Load Preferences
-preferences = Preferences.preferences()
+pref = Preferences.preferences()
 res = []
 
 def label(p):
 return p['label']
 
-for m in preferences:
+for m in pref:
 if len(m['categories']):
 om = {
 "id": m['id'],
diff --git a/web/pgadmin/tools/backup/templates/backup/js/backup.js b/web/pgadmin/tools/backup/templates/backup/js/backup.js
index 9b4f679..5d4865a 100644
--- a/web/pgadmin/tools/backup/templates/backup/js/backup.js
+++ b/web/pgadmin/tools/backup/templates/backup/js/backup.js
@@ -361,6 +361,48 @@ TODO LIST FOR BACKUP:
 
   // Callback to draw Backup Dialog for globals/server
   start_backup_global_server: function(action, item, params) {
+var i = item || pgBrowser.tree.selected(),
+  server_data = null;
+
+while (i) {
+  var node_data = pgBrowser.tree.itemData(i);
+  if (node_data._type == 'server') {
+server_data = node_data;
+break;
+  }
+
+  if (pgBrowser.tree.hasParent(i)) {
+i = $(pgBrowser.tree.parent(i));
+  } else {
+alertify.alert("{{ _("Please select server or child node from tree.") }}");
+break;
+  }
+}
+
+if (!server_data) {
+  return;
+}
+
+var module = 'paths',
+  preference_name = 'pg_bin_dir',
+  msg = '{{ _('Please set binary path for PostgreSQL Server from preferences.') }}';
+
+if (server_data.server_type == 'ppas') {
+  preference_name = 'ppas_bin_dir';
+  msg = '{{ _('Please set binary path for EDB Advanced Server from preferences.') }}';
+}
+
+var preference = pgBrowser.get_preference(module, preference_name);
+
+if(preference) {
+  if (!preference.value) {
+alertify.alert(msg);
+return;
+  }
+} else {
+  alertify.alert(S('{{ _('Failed to load preference %s of module %s') }}').sprintf(preference_name, module).value());
+  return;
+}
 
 var of_type = undefined;
 
@@ -533,6 +575,50 @@ TODO LIST FOR BACKUP:
 
   // Callback to draw Backup Dialog for objects
   backup_objects: function(action, treeItem) {
+
+var i = treeItem || pgBrowser.tree.selected(),
+  server_data = null;
+
+while (i) {
+  var node_data = pgBrowser.tree.itemData(i);
+  if (node_data._type == 'server') {
+server_data = node_data;
+break;
+  }
+
+  if (pgBrowser.tree.hasParent(i)) {
+i = $(pgBr

[pgadmin-hackers] RM1492 [pgadmin4]

2016-08-04 Thread Harshal Dhumal
Hi,

PFA patch for RM1492

Issue fixed: Generate proper queries for "View all/first 100/last 100 rows"
with table containing columns with capital letters.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/sqleditor/command.py b/web/pgadmin/tools/sqleditor/command.py
index e491fba..de3a9f8 100644
--- a/web/pgadmin/tools/sqleditor/command.py
+++ b/web/pgadmin/tools/sqleditor/command.py
@@ -365,8 +365,8 @@ class TableCommand(GridCommand):
 """
 This function is used to fetch the primary key columns.
 """
-
-manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(self.sid)
+driver = get_driver(PG_DEFAULT_DRIVER)
+manager = driver.connection_manager(self.sid)
 conn = manager.connection(did=self.did, conn_id=self.conn_id)
 
 pk_names = ''
@@ -382,7 +382,7 @@ class TableCommand(GridCommand):
 raise Exception(result)
 
 for row in result['rows']:
-pk_names += row['attname'] + ','
+pk_names += driver.qtIdent(conn, row['attname']) + ','
 primary_keys[row['attname']] = row['typname']
 
 if pk_names != '':

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch for RM1500 other issues [pgAdmin4]

2016-08-03 Thread Harshal Dhumal
Hi Dave,

Please find attached updated patch. I missed to change table __init__.py
file that why you got the error sorry for that. Also patch has changes for
both RM1500 and simplejson issue as both require changes in same file.
Please discard old patch of RM1500 and simplejson.




-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Aug 3, 2016 at 6:30 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Wed, Aug 3, 2016 at 12:43 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > This because on python 2.X simplejson throws KeyError instead of
> TypeError
> > if any error occurs while loading json data from given object. Now I have
> > handled that exception as well in attached patch.
> >
> > I'm sending this as separate patch instead part of RM1500.
>
> I still see the same error, with both patches applied. I've restarted
> the app server and cleared the browser cache and reloaded etc.
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 02057bf..8bda490 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -187,9 +187,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
   - It will return formatted output of query result
 as per client model format for index constraint node
 
-* _cltype_formatter(self, type):
+* _cltype_formatter(type): (staticmethod)
   - We need to remove [] from type and append it
-after length/precision so we will set flag for
+after length/precision so we will send flag for
 sql template
 
 * _parse_format_columns(self, data, mode=None):
@@ -627,17 +627,16 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 column['isdup'], column['attndims'], column['atttypmod']
 )
 
-import re
 # If we have length & precision both
 matchObj = re.search(r'(\d+),(\d+)', fulltype)
 if matchObj:
-column['attlen'] = matchObj.group(1)
-column['attprecision'] = matchObj.group(2)
+column['attlen'] = int(matchObj.group(1))
+column['attprecision'] = int(matchObj.group(2))
 else:
 # If we have length only
 matchObj = re.search(r'(\d+)', fulltype)
 if matchObj:
-column['attlen'] = matchObj.group(1)
+column['attlen'] = int(matchObj.group(1))
 column['attprecision'] = None
 else:
 column['attlen'] = None
@@ -1045,7 +1044,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 # Filter inherited columns from all columns
 if 'columns' in data and len(data['columns']) > 0 \
 and len(all_columns) > 0:
-columns = []
 for row in data['columns']:
 for i, col in enumerate(all_columns):
 # If both name are same then remove it
@@ -1271,24 +1269,22 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 except Exception as e:
 return internal_server_error(errormsg=str(e))
 
-def _cltype_formatter(self, type):
+@staticmethod
+def _cltype_formatter(data_type):
 """
 
 Args:
-data: Type string
+data_type: Type string
 
 Returns:
 We need to remove [] from type and append it
-after length/precision so we will set flag for
+after length/precision so we will send flag for
 sql template
 """
-if '[]' in type:
-type = type.replace('[]', '')
-self.hasSqrBracket = True
+if '[]' in data_type:
+return data_type[:-2], True
 else:
-self.hasSqrBracket = False
-
-return type
+return data_type, False
 
 def _parse_format_columns(self, data, mode=None):
 """
@@ -1313,9 +1309,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 if 'attacl' in c:
 c['attacl'] = parse_priv_to_db(c['attacl'], self.column_acl)
 
-# check type for '[]' in it
- 

[pgadmin-hackers] patch for RM1450 [pgAdmin4]

2016-08-03 Thread Harshal Dhumal
Hi,

PFA patch for RM1450.


Changes: Added save password option in sever create mode.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/__init__.py b/web/pgadmin/browser/server_groups/servers/__init__.py
index 5128e74..5ea3d82 100644
--- a/web/pgadmin/browser/server_groups/servers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/__init__.py
@@ -570,6 +570,8 @@ class ServerNode(PGChildNodeView):
 )
 )
 
+server = None
+
 try:
 server = Server(
 user_id=current_user.id,
@@ -596,8 +598,10 @@ class ServerNode(PGChildNodeView):
 manager.update(server)
 conn = manager.connection()
 
+is_password =  False
 if 'password' in data and data["password"] != '':
 # login with password
+is_password = True
 password = data['password']
 password = encrypt(password, current_user.password)
 else:
@@ -618,6 +622,10 @@ class ServerNode(PGChildNodeView):
 errormsg=gettext("Unable to connect to server:\n\n%s" % errmsg)
 )
 else:
+if 'save_password' in data and data['save_password'] and is_password:
+setattr(server, 'password', password)
+db.session.commit()
+
 user = manager.user_info
 connected = True
 icon = "icon-pg"
diff --git a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
index 0a64143..601cdeb 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
+++ b/web/pgadmin/browser/server_groups/servers/templates/servers/servers.js
@@ -580,7 +580,8 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   username: '{{ username }}',
   role: null,
   connect_now: true,
-  password: undefined
+  password: undefined,
+  save_password: false
 },
 // Default values!
 initialize: function(attrs, args) {
@@ -641,6 +642,12 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 return m.get('connect_now') && m.isNew();
   }
 },{
+  id: 'save_password', controlLabel:'{{ _('Save Password') }}', type: 'checkbox',
+  group: "{{ 'Connection' }}", mode: ['create'], deps: ['connect_now'],
+  visible: function(m) {
+return m.get('connect_now') && m.isNew();
+  }
+},{
   id: 'role', label:'{{ _('Role') }}', type: 'text', group: "{{ 'Connection' }}",
   mode: ['properties', 'edit', 'create'], disabled: 'isConnected'
 },{

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Patch for RM1500 other issues [pgAdmin4]

2016-08-03 Thread Harshal Dhumal
Hi Dave,

This because on python 2.X simplejson throws KeyError instead of TypeError
if any error occurs while loading json data from given object. Now I have
handled that exception as well in attached patch.

I'm sending this as separate patch instead part of RM1500.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Aug 3, 2016 at 4:12 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Wed, Aug 3, 2016 at 7:36 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA patch for RM1500.
> >
> > Changes/Issues fixed:
> >
> > 1] datamodel.js: For collection type added check before adding model into
> > "changed" list instead of adding it blindly.
> >
> > 2] Type casting from str to int of column properties like attlen,
> > attpricision.
> >
> > 3] Added missing data formating when adding new column to existing table
> > (from table edit mode).
> >
> > 4] Added more validation for Foreign key constraint.
> >
> > 5] Column.js: Column grid (in table edit mode) show proper disabled color
> > for disabled cell when grid renders.
> >
> > 6] All constraints and index js added idattribute to distinguish which
> > s/constraint or s/index is updated on server side.
> >
> > 7] Column update.sql: Fixed sql when altering column data type. The issue
> > was when we alter data type from which has length and precision to data
> type
> > which don't have these properties and vice versa.
> > For e.g. alter data type numeric(10,12) to real (and vice versa)
> >
> > 8] Renaming constraint (RM1500).
>
> I get the following error when renaming a primary key. I have
> restarted my app sever and done a hard reload/clear cache on my
> browser. The generated SQL is:
>
> ALTER TABLE public.foo
> RENAME CONSTRAINT foo_pkey TO foo_pkey1;
>
>
> 2016-08-03 11:39:43,764: INFO werkzeug: 127.0.0.1 - - [03/Aug/2016
> 11:39:43] "PUT /browser/table/obj/1/1/12403/2200/158521 HTTP/1.1" 500
> -
> Traceback (most recent call last):
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 2000, in __call__
> return self.wsgi_app(environ, start_response)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1991, in wsgi_app
> response = self.make_response(self.handle_exception(e))
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1567, in handle_exception
> reraise(exc_type, exc_value, tb)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1988, in wsgi_app
> response = self.full_dispatch_request()
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1641, in full_dispatch_request
> rv = self.handle_user_exception(e)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1544, in handle_user_exception
> reraise(exc_type, exc_value, tb)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/flask/app.py",
> line 1639, in full_dispatch_request
> rv = self.dispatch_request()
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/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-packages/flask/views.py",
> line 84, in view
> return self.dispatch_request(*args, **kwargs)
>   File "/Users/dpage/git/pgadmin4/web/pgadmin/browser/utils.py", line
> 235, in dispatch_request
> return method(*args, **kwargs)
>   File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
> line 331, in wrap
> return f(*args, **kwargs)
>   File
> "/Users/dpage/git/pgadmin4/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py",
> line 1446, in update
> data[k] = json.loads(v, encoding='utf-8')
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/__init__.py",
> line 533, in loads
> return cls(encoding=encoding, **kw).decode(s)
>   File
> "/Users/dpage/.virtualenvs/pgadmin4/lib/python2.7/site-packages/simplejson/decoder.py",
> line 370, in decode
> obj, end = self.raw_decode(s)
>   File
> "/Users/dpage/.virtualenvs/p

[pgadmin-hackers] Patch for RM1500 other issues [pgAdmin4]

2016-08-03 Thread Harshal Dhumal
Hi,

PFA patch for RM1500.

Changes/Issues fixed:

1] datamodel.js: For collection type added check before adding model into
"changed" list instead of adding it blindly.

2] Type casting from str to int of column properties like attlen,
attpricision.

3] Added missing data formating when adding new column to existing table
(from table edit mode).

4] Added more validation for Foreign key constraint.

5] Column.js: Column grid (in table edit mode) show proper disabled color
for disabled cell when grid renders.

6] All constraints and index js added idattribute to distinguish which
s/constraint or s/index is updated on server side.

7] Column update.sql: Fixed sql when altering column data type. The issue
was when we alter data type from which has length and precision to data
type which don't have these properties and vice versa.
For e.g. alter data type numeric(10,12) to real (and vice versa)

8] Renaming constraint (RM1500).

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
index 02057bf..ece103f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py
@@ -187,9 +187,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
   - It will return formatted output of query result
 as per client model format for index constraint node
 
-* _cltype_formatter(self, type):
+* _cltype_formatter(type): (staticmethod)
   - We need to remove [] from type and append it
-after length/precision so we will set flag for
+after length/precision so we will send flag for
 sql template
 
 * _parse_format_columns(self, data, mode=None):
@@ -627,17 +627,16 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 column['isdup'], column['attndims'], column['atttypmod']
 )
 
-import re
 # If we have length & precision both
 matchObj = re.search(r'(\d+),(\d+)', fulltype)
 if matchObj:
-column['attlen'] = matchObj.group(1)
-column['attprecision'] = matchObj.group(2)
+column['attlen'] = int(matchObj.group(1))
+column['attprecision'] = int(matchObj.group(2))
 else:
 # If we have length only
 matchObj = re.search(r'(\d+)', fulltype)
 if matchObj:
-column['attlen'] = matchObj.group(1)
+column['attlen'] = int(matchObj.group(1))
 column['attprecision'] = None
 else:
 column['attlen'] = None
@@ -1045,7 +1044,6 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 # Filter inherited columns from all columns
 if 'columns' in data and len(data['columns']) > 0 \
 and len(all_columns) > 0:
-columns = []
 for row in data['columns']:
 for i, col in enumerate(all_columns):
 # If both name are same then remove it
@@ -1271,24 +1269,22 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 except Exception as e:
 return internal_server_error(errormsg=str(e))
 
-def _cltype_formatter(self, type):
+@staticmethod
+def _cltype_formatter(data_type):
 """
 
 Args:
-data: Type string
+data_type: Type string
 
 Returns:
 We need to remove [] from type and append it
-after length/precision so we will set flag for
+after length/precision so we will send flag for
 sql template
 """
-if '[]' in type:
-type = type.replace('[]', '')
-self.hasSqrBracket = True
+if '[]' in data_type:
+return data_type[:-2], True
 else:
-self.hasSqrBracket = False
-
-return type
+return data_type, False
 
 def _parse_format_columns(self, data, mode=None):
 """
@@ -1313,9 +1309,9 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings):
 if 'attacl' in c:
 c['attacl'] = parse_priv_to_db(c['attacl'], self.column_acl)
 
-# check type for '[]' in it
-c['cltype'] = self._cltype_formatter(c['cltype'])
-c['hasSqrBracket'] = self.hasSqrBracket
+if 'cltype' in c:
+# check type for '[]'

Re: [pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-27 Thread Harshal Dhumal
Hi,

PFA updated patch for RM1260 (V4).

Fixed create and delete operations for foreign table.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jul 27, 2016 at 6:53 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> Hi Harshal,
>
> During testing, I found that create, and delete operation on foreign table
> is not working.
> Foreign table node uses, it's own version of Select2 Control, which should
> have used maximum functionalities from the original NodeAjaxOptionsControl
> for consistency reason.
> Hence - I have made the changes.
>
> Can you please take a look at the create, and delete operations, and
> submit combined patch for all those problems?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
> On Wed, Jul 27, 2016 at 3:54 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> and patch file
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Wed, Jul 27, 2016 at 3:49 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA updated patch for RM1260.
>>>
>>> In addition to RM1260 issue I have added following changes in this patch.
>>> 1] datamodel.js: Added option check against undefined.
>>> 2] foreign key: fixed first empty option issue.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Thu, Jul 7, 2016 at 5:08 PM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
>>>> Sure - I will do.
>>>>
>>>> --
>>>>
>>>> Thanks & Regards,
>>>>
>>>> Ashesh Vashi
>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>> <http://www.enterprisedb.com>
>>>>
>>>>
>>>> *http://www.linkedin.com/in/asheshvashi*
>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>
>>>> On Thu, Jul 7, 2016 at 2:33 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>
>>>>> Ashesh, can you review/commit please?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> On Thu, Jul 7, 2016 at 7:50 AM, Harshal Dhumal <
>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> By mistake I deleted a line which was not supposed to be deleted, and
>>>>>> that line of code was initialization of select2.
>>>>>>
>>>>>> --
>>>>>> *Harshal Dhumal*
>>>>>> *Software Engineer*
>>>>>>
>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Thu, Jul 7, 2016 at 12:13 PM, Ashesh Vashi <
>>>>>> ashesh.va...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi Harshal,
>>>>>>>
>>>>>>> Can you please explain - what was missing in the last patch?
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>> Thanks & Regards,
>>>>>>>
>>>>>>> Ashesh Vashi
>>>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>>>> <http://www.enterprisedb.com>
>>>>>>>
>>>>>>>
>>>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>>>>
>>>>>>> On Thu, Jul 7, 2016 at 12:12 PM, Harshal Dhumal <
>>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> PFA updated patch for issue RM1260
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Harshal Dhumal*
>>>>>&

Re: [pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-27 Thread Harshal Dhumal
and patch file

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jul 27, 2016 at 3:49 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA updated patch for RM1260.
>
> In addition to RM1260 issue I have added following changes in this patch.
> 1] datamodel.js: Added option check against undefined.
> 2] foreign key: fixed first empty option issue.
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Jul 7, 2016 at 5:08 PM, Ashesh Vashi <
> ashesh.va...@enterprisedb.com> wrote:
>
>> Sure - I will do.
>>
>> --
>>
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>> <http://www.enterprisedb.com>
>>
>>
>> *http://www.linkedin.com/in/asheshvashi*
>> <http://www.linkedin.com/in/asheshvashi>
>>
>> On Thu, Jul 7, 2016 at 2:33 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Ashesh, can you review/commit please?
>>>
>>> Thanks.
>>>
>>> On Thu, Jul 7, 2016 at 7:50 AM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> By mistake I deleted a line which was not supposed to be deleted, and
>>>> that line of code was initialization of select2.
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>> On Thu, Jul 7, 2016 at 12:13 PM, Ashesh Vashi <
>>>> ashesh.va...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Harshal,
>>>>>
>>>>> Can you please explain - what was missing in the last patch?
>>>>>
>>>>> --
>>>>>
>>>>> Thanks & Regards,
>>>>>
>>>>> Ashesh Vashi
>>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>>> <http://www.enterprisedb.com>
>>>>>
>>>>>
>>>>> *http://www.linkedin.com/in/asheshvashi*
>>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>>
>>>>> On Thu, Jul 7, 2016 at 12:12 PM, Harshal Dhumal <
>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> PFA updated patch for issue RM1260
>>>>>>
>>>>>> --
>>>>>> *Harshal Dhumal*
>>>>>> *Software Engineer*
>>>>>>
>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Thu, Jul 7, 2016 at 12:04 PM, Harshal Dhumal <
>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>> Please ignore this patch as this has some minor issue. I'll sent
>>>>>>> updated one.
>>>>>>>
>>>>>>> --
>>>>>>> *Harshal Dhumal*
>>>>>>> *Software Engineer*
>>>>>>>
>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>> On Wed, Jul 6, 2016 at 5:30 PM, Harshal Dhumal <
>>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> PFA patch for issue RM1260.
>>>>>>>>
>>>>>>>> Changes: Issue wasn't related to foreign table but was due the
>>>>>>>> Select2 control. Now I have improved select2 control to handle null 
>>>>>>>> value
>>>>>>>> in multi-select mode. Initial it was returning "null" instead it should
>>>>>>>> return [] (empty array).
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Harshal Dhumal*
>>>>>>>> *Software Engineer*
>>>>>>>>
>>>>>>>> EnterpriseDB India: http://www.enter

Re: [pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-27 Thread Harshal Dhumal
Hi,

PFA updated patch for RM1260.

In addition to RM1260 issue I have added following changes in this patch.
1] datamodel.js: Added option check against undefined.
2] foreign key: fixed first empty option issue.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jul 7, 2016 at 5:08 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com>
wrote:

> Sure - I will do.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
> On Thu, Jul 7, 2016 at 2:33 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Ashesh, can you review/commit please?
>>
>> Thanks.
>>
>> On Thu, Jul 7, 2016 at 7:50 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> By mistake I deleted a line which was not supposed to be deleted, and
>>> that line of code was initialization of select2.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Thu, Jul 7, 2016 at 12:13 PM, Ashesh Vashi <
>>> ashesh.va...@enterprisedb.com> wrote:
>>>
>>>> Hi Harshal,
>>>>
>>>> Can you please explain - what was missing in the last patch?
>>>>
>>>> --
>>>>
>>>> Thanks & Regards,
>>>>
>>>> Ashesh Vashi
>>>> EnterpriseDB INDIA: Enterprise PostgreSQL Company
>>>> <http://www.enterprisedb.com>
>>>>
>>>>
>>>> *http://www.linkedin.com/in/asheshvashi*
>>>> <http://www.linkedin.com/in/asheshvashi>
>>>>
>>>> On Thu, Jul 7, 2016 at 12:12 PM, Harshal Dhumal <
>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> PFA updated patch for issue RM1260
>>>>>
>>>>> --
>>>>> *Harshal Dhumal*
>>>>> *Software Engineer*
>>>>>
>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>> The Enterprise PostgreSQL Company
>>>>>
>>>>> On Thu, Jul 7, 2016 at 12:04 PM, Harshal Dhumal <
>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>> Please ignore this patch as this has some minor issue. I'll sent
>>>>>> updated one.
>>>>>>
>>>>>> --
>>>>>> *Harshal Dhumal*
>>>>>> *Software Engineer*
>>>>>>
>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>> The Enterprise PostgreSQL Company
>>>>>>
>>>>>> On Wed, Jul 6, 2016 at 5:30 PM, Harshal Dhumal <
>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> PFA patch for issue RM1260.
>>>>>>>
>>>>>>> Changes: Issue wasn't related to foreign table but was due the
>>>>>>> Select2 control. Now I have improved select2 control to handle null 
>>>>>>> value
>>>>>>> in multi-select mode. Initial it was returning "null" instead it should
>>>>>>> return [] (empty array).
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> *Harshal Dhumal*
>>>>>>> *Software Engineer*
>>>>>>>
>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>
>>>>>
>>>>
>>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


[pgadmin-hackers] Fix for RM1154: Show proper error message for already delete object [pgadmin4]

2016-07-26 Thread Harshal Dhumal
Hi,

PFA patch for rm1154.


Issue fixed: Show proper error message if try to delete already deleted
object.


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
index 1b7882d..e35d076 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/__init__.py
@@ -599,6 +599,9 @@ class DatabaseView(PGChildNodeView):
 return make_json_response(
 success=0,
 errormsg=_(
+'Error: Object not found.'
+),
+info=_(
 'The specified database could not be found.\n'
 )
 )
diff --git a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
index f159a05..ac8b476 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/casts/__init__.py
@@ -454,6 +454,17 @@ class CastView(PGChildNodeView):
 if not status:
 return internal_server_error(errormsg=res)
 
+if not res['rows']:
+return make_json_response(
+success=0,
+errormsg=gettext(
+'Error: Object not found.'
+),
+info=gettext(
+'The specified cast object could not be found.\n'
+)
+)
+
 # drop cast
 result = res['rows'][0]
 sql = render_template("/".join([self.template_path, 'delete.sql']),
diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
index f429356..5ae5a0f 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py
@@ -452,6 +452,17 @@ class EventTriggerView(PGChildNodeView):
 if not status:
 return internal_server_error(errormsg=name)
 
+if name is None:
+return make_json_response(
+success=0,
+errormsg=gettext(
+'Error: Object not found.'
+),
+info=gettext(
+'The specified event trigger could not be found.\n'
+)
+)
+
 sql = render_template("/".join([self.template_path, 'delete.sql']), name=name, cascade=cascade)
 status, res = self.conn.execute_scalar(sql)
 if not status:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
index f4c1e9e..1f70a1a 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/extensions/__init__.py
@@ -310,6 +310,18 @@ class ExtensionView(PGChildNodeView):
 status, name = self.conn.execute_scalar(SQL)
 if not status:
 return internal_server_error(errormsg=name)
+
+if name is None:
+return make_json_response(
+success=0,
+errormsg=gettext(
+'Error: Object not found.'
+),
+info=gettext(
+'The specified extension could not be found.\n'
+)
+)
+
 # drop extension
 SQL = render_template("/".join(
 [self.template_path, 'delete.sql']
diff --git a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
index 8efd50f..2103f50 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/foreign_data_wrappers/__init__.py
@@ -478,6 +478,17 @@ class ForeignDataWrapperView(PGChildNodeView):
 status, name = self.conn.execute_scalar(sql)
 if not status:
 return internal_server_error(errormsg=name)
+
+if name is None:
+return make_json_response(
+success=0,
+errormsg=gettext(
+'Error: Object not found.'
+),
+  

[pgadmin-hackers] patch for RM1497

2016-07-25 Thread Harshal Dhumal
Hi,

PFA attached for rm1497

Issue: fixed js error while re-rendering shubnode grid

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
index b404d46..6bd6195 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/foreign_key/templates/foreign_key/js/foreign_key.js
@@ -371,6 +371,11 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
   titleTmpl({label: data.label})
 );
 
+  // Clean up existing grid if any (in case of re-render)
+  if (self.grid) {
+self.grid.remove();
+  }
+
   $gridBody.append(self.generateHeader(data));
 
   var gridSchema = _.clone(this.gridSchema);
diff --git a/web/pgadmin/browser/server_groups/servers/static/js/variable.js b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
index 565c266..1413dbc 100644
--- a/web/pgadmin/browser/server_groups/servers/static/js/variable.js
+++ b/web/pgadmin/browser/server_groups/servers/static/js/variable.js
@@ -380,6 +380,11 @@
   titleTmpl(data)
 );
 
+  // Clean up existing grid if any (in case of re-render)
+  if (self.grid) {
+self.grid.remove();
+  }
+
   var gridSchema = _.clone(this.gridSchema);
 
   _.each(gridSchema.columns, function(col) {
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 985ed46..eadea8a 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -967,7 +967,8 @@
   return this;
 },
 showGridControl: function(data) {
-  var gridHeader = _.template([
+  var self = this,
+  gridHeader = _.template([
   '',
   '  <%-label%>',
   '  ><%-add_label%>',
@@ -976,6 +977,11 @@
 gridHeader(data)
 );
 
+  // Clean up existing grid if any (in case of re-render)
+  if (self.grid) {
+self.grid.remove();
+  }
+
   if (!(data.subnode)) {
 return '';
   }
@@ -983,8 +989,7 @@
   var subnode = data.subnode.schema ? data.subnode : data.subnode.prototype,
   gridSchema = Backform.generateGridColumnsFromModel(
 data.node_info, subnode, this.field.get('mode'), data.columns
-),
-  self = this;
+);
 
   // Set visibility of Add button
   if (data.mode == 'properties') {
@@ -1201,7 +1206,8 @@
   return this;
 },
 showGridControl: function(data) {
-  var gridHeader = ["",
+  var self = this,
+  gridHeader = ["",
   "  " + data.label + "" ,
   "  Add",
   ""].join("\n");
@@ -1210,9 +1216,14 @@
   var subnode = data.subnode.schema ? data.subnode : data.subnode.prototype,
   gridSchema = Backform.generateGridColumnsFromModel(
 data.node_info, subnode, this.field.get('mode'), data.columns, data.schema_node
-), self = this,
+),
   pgBrowser = window.pgAdmin.Browser;
 
+  // Clean up existing grid if any (in case of re-render)
+  if (self.grid) {
+self.grid.remove();
+  }
+
   // Set visibility of Add button
   if (data.disabled || data.canAdd == false) {
 $(gridBody).find("button.add").remove();

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] patch for RM1460 [pgAdmin4]

2016-07-25 Thread Harshal Dhumal
Hi Dave,

Can you please try again with clean cache. Above mentioned scenario is
working fine for me.

Thanks.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Jul 22, 2016 at 9:13 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Fri, Jul 22, 2016 at 10:26 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA attached patch to show save as option always and to show menu save
> > option only when file is changed.
>
> This doesn't seem to be working - if I open the query tool, write
> something, and save the file, the Save button and drop-down menu are
> then disabled so I cannot use Save As.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] patch for RM1460 [pgAdmin4]

2016-07-22 Thread Harshal Dhumal
Hi,

PFA attached patch to show save as option always and to show menu save
option only when file is changed.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jul 21, 2016 at 6:18 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> Works nicely - committed!
>
> One change I think we should make (please provide a patch when you get
> a minute) is to always allow the dropdown menu and Save As to be used,
> regardless of whether the file is dirty. Save should only be available
> when there are changes of course.
>
> Thanks!
>
> On Wed, Jul 20, 2016 at 1:12 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA patch for RM1460
> >
> > Changes:
> > - Opening a file should set the tab name to the filename
> > - Editing a file should add a * to the tab name to indicate the file is
> > dirty
> > - Saving changes to a file should clear the *
> > - The Save button should have a drop-down menu, with a Save As option.
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> >
> > --
> > Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> > To make changes to your subscription:
> > http://www.postgresql.org/mailpref/pgadmin-hackers
> >
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 6db2310..8961c55 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -2065,7 +2065,7 @@ define(
 self.setTitle(self.gridView.current_file.replace(/^\/|\/$/g, ''));
 // disable save button on file save
 $("#btn-save").prop('disabled', true);
-$("#btn-file-menu-dropdown").prop('disabled', true);
+$("#btn-file-menu-save").css('display', 'none');
   }
 },
 error: function(e) {
@@ -2080,6 +2080,7 @@ define(
   var self = this;
   if(query_tool_obj.getValue().length == 0) {
 $("#btn-save").prop('disabled', true);
+$("#btn-file-menu-save").css('display', 'none');
 $("#btn-file-menu-dropdown").prop('disabled', true);
   } else {
 if(self.gridView.current_file) {
@@ -2087,6 +2088,7 @@ define(
   self.setTitle(title);
 }
 $("#btn-save").prop('disabled', false);
+$("#btn-file-menu-save").css('display', 'block');
 $("#btn-file-menu-dropdown").prop('disabled', false);
   }
 },

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Re: [pgAdmin4][Patch]: RM#1293 - SQL pane is not displaying GRANT queries in Function, Procedure and Trigger node

2016-07-22 Thread Harshal Dhumal
Hi,

PFA rebased patch for RM1293 and RM1294.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jun 6, 2016 at 7:17 PM, Surinder Kumar <
surinder.ku...@enterprisedb.com> wrote:

> Hi,
>
> Please find updated patch:
> *Issue*: Code changes are not consistent with the present code in
> functions/__init__.py, like don't rename variable func_def to
> func_defintion until it is required.
> Review comment given by Ashesh personally.
>
> Please review.
>
> On Fri, Jun 3, 2016 at 3:31 PM, Surinder Kumar <
> surinder.ku...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> Please find attached patch for:
>> 1. RM#1293 - SQL pane is not displaying GRANT queries in functions node
>> 2. RM#1294 - Comments are not visible in sql pane for trigger functions
>> and functions
>>
>> Explanation:
>> Previously we we using 'get_defintion.sql' template to generate SQL for
>> SQL pane for functions, procedure & trigger functions node.
>> but GRANT statements and COMMENTS changes were missing. In order to fix
>> that, now we have used both 'create.sql' and 'get_definition.sql' templates
>> to generate full SQL query
>> for SQL pane.
>>
>> Please review.
>>
>> On Thu, Jun 2, 2016 at 7:32 PM, Surinder Kumar <
>> surinder.ku...@enterprisedb.com> wrote:
>>
>>> Please ignore this patch. I will send another patch.
>>>
>>> On Thu, Jun 2, 2016 at 7:25 PM, Surinder Kumar <
>>> surinder.ku...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Please find attached patch for RM#1293.
>>>> Add support to display GRANT privilege query in SQL Pane.
>>>>
>>>> Please review.
>>>>
>>>> Thanks,
>>>> Surinder Kumar
>>>>
>>>
>>>
>>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
index 7d5d129..75ba022 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/__init__.py
@@ -889,10 +889,31 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 scid: Schema Id
 fnid: Function Id
 """
+resp_data = self._fetch_properties(gid, sid, did, scid, fnid)
+# Fetch the function definition.
+args = ''
+cnt = 1
+if 'arguments' in resp_data:
+for a in resp_data['arguments']:
+if (('argmode' in a and a['argmode'] != 'OUT' and
+a['argmode'] is not None
+  ) or 'argnode' not in a):
+if 'argmode' in a:
+args += a['argmode'] + " "
+if 'argname' in a and a['argname'] != ''\
+and a['argname'] is not None:
+args += self.qtIdent(
+self.conn, a['argname']) + " "
+if 'argtype' in a:
+args += a['argtype']
+if cnt < len(resp_data['arguments']):
+args += ', '
+cnt += 1
+
+resp_data['func_args'] = args.strip(' ')
 
 if self.node_type == 'procedure':
 object_type = 'procedure'
-resp_data = self._fetch_properties(gid, sid, did, scid, fnid)
 
 # Get SQL to create Function
 status, func_def = self._get_sql(gid, sid, did, scid, resp_data,
@@ -901,16 +922,38 @@ class FunctionView(PGChildNodeView, DataTypeReader):
 return internal_server_error(errormsg=func_def)
 
 name = resp_data['pronamespace'] + "." + resp_data['name_with_args']
+
+# Create mode
+func_def = render_template("/".join([self.sql_template_path,
+'create.sql']),
+   data=resp_data, query_type="create")
 else:
 object_type = 'function'
-# Fetch the function definition.
+
+# Get Schema Name from its OID.
+if 'pronamespace' in resp_data:
+resp_data['pronamespace'] = self._get_schema(resp_data[
+'pronamespace'])
+
+# Parse privilege data
+if 'acl' in resp_data:
+   

[pgadmin-hackers] patch for RM1460 [pgAdmin4]

2016-07-20 Thread Harshal Dhumal
Hi,

PFA patch for RM1460

Changes:
- Opening a file should set the tab name to the filename
- Editing a file should add a * to the tab name to indicate the file is
dirty
- Saving changes to a file should clear the *
- The Save button should have a drop-down menu, with a Save As option.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index 67cf107..1611887 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -30,6 +30,22 @@
 
 
 
+
+ Toggle Dropdown
+
+
+
+
+{{ _('Save') }}
+
+
+
+
+{{ _('Save as') }}
+
+
+
 
 
 
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 5544135..6db2310 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -152,6 +152,8 @@ define(
   events: {
 "click .btn-load-file": "on_file_load",
 "click #btn-save": "on_save",
+"click #btn-file-menu-save": "on_save",
+"click #btn-file-menu-save-as": "on_save_as",
 "click #btn-add-row": "on_add",
 "click #btn-filter": "on_show_filter",
 "click #btn-include-filter": "on_include_filter",
@@ -713,6 +715,22 @@ define(
 );
   },
 
+  // Callback function for Save button click.
+  on_save_as: function(ev) {
+var self = this;
+
+this._stopEventPropogation(ev);
+this._closeDropDown(ev);
+
+// Trigger the save signal to the SqlEditorController class
+self.handler.trigger(
+'pgadmin-sqleditor:button:save',
+self,
+self.handler,
+true
+);
+  },
+
   // Callback function for filter button click.
   on_show_filter: function() {
 var self = this;
@@ -1089,7 +1107,7 @@ define(
   // only in query editor tool
   if (self.is_query_tool) {
 self.get_preferences();
-self.gridView.query_tool_obj.on('change', self._on_query_change, self);
+self.gridView.query_tool_obj.on('change', self._on_query_change.bind(self));
   }
 
   // Listen on events come from SQLEditorView for the button clicked.
@@ -1183,8 +1201,8 @@ define(
   $('#btn-filter').addClass('btn-default');
   $('#btn-filter-dropdown').addClass('btn-default');
 }
-
 $("#btn-save").prop('disabled', true);
+$("#btn-file-menu-dropdown").prop('disabled', true);
 $("#btn-copy-row").prop('disabled', true);
 $("#btn-paste-row").prop('disabled', true);
 
@@ -1345,6 +1363,7 @@ define(
   }
   else {
 $("#btn-save").prop('disabled', true);
+$("#btn-file-menu-dropdown").prop('disabled', true);
 $("#btn-add-row").prop('disabled', true);
 $("#btn-copy-row").prop('disabled', true);
 $("#btn-paste-row").prop('disabled', true);
@@ -1750,10 +1769,12 @@ define(
   model.trigger('backgrid:row:mark:deletion', model);
 
   // Enable/Disable Save button
-  if (self.changedModels.length > 0)
+  if (self.changedModels.length > 0) {
 $("#btn-save").prop('disabled', false);
-  else
+  } else {
 $("#btn-save").prop('disabled', true);
+$("#btn-file-menu-dropdown").prop('disabled', true);
+  }
 },
 
 /* This is a callback function when backgrid cell
@@ -1851,7 +1872,7 @@ define(
  * the ajax call to save the data into the database server.
  * and will open save file dialog conditionally.
  */
-_save: function() {
+_save: function(view, controller, save_as) {
   var self = this,
   data = [],
   save_data = true;
@@ -1860,7 +1881,7 @@ define(
   if (self.is_query_tool) {
 
 var current_file = self.gridView.current_file;
-if (!_.isUndefined(curre

Re: [pgadmin-hackers] PATCH: Fix the issue for saving query output as CSV

2016-07-18 Thread Harshal Dhumal
Hi,

PFA rebased patch RM1405 (version 4)

Neel will be sending patch for QT issue for same functionality.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jul 18, 2016 at 4:02 PM, Dave Page <dp...@pgadmin.org> wrote:

> Perfect, thanks!
>
> On Mon, Jul 18, 2016 at 11:24 AM, Neel Patel <neel.pa...@enterprisedb.com>
> wrote:
>
>> Yes. I am just testing with different OS. I will send it next 1-2 hour.
>>
>> Is it fine ?
>>
>> Thanks,
>> Neel Patel
>>
>> On Mon, Jul 18, 2016 at 3:53 PM, Dave Page <dp...@pgadmin.org> wrote:
>>
>>> Any chance of getting that in the next couple of hours so I can get it
>>> into beta 3?
>>>
>>> On Mon, Jul 18, 2016 at 11:18 AM, Dave Page <dp...@pgadmin.org> wrote:
>>>
>>>> Thanks!
>>>>
>>>> On Mon, Jul 18, 2016 at 10:42 AM, Neel Patel <
>>>> neel.pa...@enterprisedb.com> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> Yes, it will break in runtime. If we need to support downloading at
>>>>> server side then we need to change the runtime code.
>>>>> I will send the patch for runtime to support server side download CSV
>>>>> file.
>>>>>
>>>>> Thanks,
>>>>> Neel Patel
>>>>>
>>>>> On Fri, Jul 15, 2016 at 3:05 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>>>
>>>>>> Hi
>>>>>>
>>>>>> This seems to break downloads in the runtime. It works in Safari and
>>>>>> Chrome, but in the runtime the suggested filename is
>>>>>> "6980287?query=SELECT+*+FROM+pem.probe_column%0AORDER+BY+id%0AASC+=probe_column.csv",
>>>>>> and after changing that and hitting OK, the "Downloading file" dialogue 
>>>>>> is
>>>>>> shown indefinitely.
>>>>>>
>>>>>> On Wed, Jul 13, 2016 at 1:16 PM, Harshal Dhumal <
>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> PFA rebased patch for RM1405
>>>>>>>
>>>>>>> --
>>>>>>> *Harshal Dhumal*
>>>>>>> *Software Engineer*
>>>>>>>
>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>
>>>>>>> On Wed, Jul 13, 2016 at 5:15 PM, Harshal Dhumal <
>>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>>
>>>>>>>> Yes sure
>>>>>>>>
>>>>>>>> --
>>>>>>>> *Harshal Dhumal*
>>>>>>>> *Software Engineer*
>>>>>>>>
>>>>>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>>>>>> The Enterprise PostgreSQL Company
>>>>>>>>
>>>>>>>> On Wed, Jul 13, 2016 at 5:10 PM, Dave Page <dp...@pgadmin.org>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi
>>>>>>>>>
>>>>>>>>> Can you rebase this please?
>>>>>>>>>
>>>>>>>>> Thanks.
>>>>>>>>>
>>>>>>>>> On Mon, Jul 11, 2016 at 9:16 AM, Harshal Dhumal <
>>>>>>>>> harshal.dhu...@enterprisedb.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> PFA patch for RM1405. Also to allow download in runtime we will
>>>>>>>>>> still need patch
>>>>>>>>>> <https://www.postgresql.org/message-id/CACCA4P3JOe40WYMGjhpSWYGR%3DWuvRbbp2gfDKLnU%2B1rXuW9Www%40mail.gmail.com>
>>>>>>>>>> sent by Neel.
>>>>>>>>>>
>>>>>>>>>> Changes: To download query result to CSV directly from server and
>>>>>>>>>> not to use download attr. of anchor tag () as it's not support by 
>>>>>>>>>> all of
>>>>>>>>>> major browsers (e.g. Safari).
>>>>>>>>>>

Re: [pgadmin-hackers] Regarding issue 1241

2016-07-18 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1241

Changes: 1. Altered variable control to make its UI consistence with
privileges and Security labels.
2. Changed datamodel.js to handle duplicate rows at datamodel level and not
UI/Control level. (See variable control for example)



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jun 15, 2016 at 7:57 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> On Wed, Jun 15, 2016 at 7:24 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>>
>>
>> On Wed, Jun 15, 2016 at 2:08 PM, Ashesh Vashi <
>> ashesh.va...@enterprisedb.com> wrote:
>>
>>> On Wed, Jun 15, 2016 at 6:25 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>
>>>> On Wed, Jun 15, 2016 at 1:49 PM, Ashesh Vashi
>>>> <ashesh.va...@enterprisedb.com> wrote:
>>>> > On Thu, Jun 2, 2016 at 1:59 PM, Dave Page <dp...@pgadmin.org> wrote:
>>>> >>
>>>> >>
>>>> >>
>>>> >> On Tue, May 31, 2016 at 8:53 PM, Harshal Dhumal
>>>> >> <harshal.dhu...@enterprisedb.com> wrote:
>>>> >>>
>>>> >>> Hi Dave,
>>>> >>>
>>>> >>> Regarding Issue 1241:
>>>> >>>
>>>> >>> We have added header section for parameter tab deliberately so that
>>>> we
>>>> >>> can force user to select parameter name (and therefore parameter's
>>>> data
>>>> >>> type) before adding new row. This is required because behavior of
>>>> second
>>>> >>> cell (Value cell) is dependent on what parameter name user has
>>>> selected in
>>>> >>> first cell (Name cell). See attached screen-shot.
>>>> >>>
>>>> >>> For example:
>>>> >>> 1. If user selects parameter 'array_nulls' then value for this
>>>> should be
>>>> >>> either true or false (and hence switch cell).
>>>> >>> 2. If user selects parameter 'cpu_index_tuple_cost' then value for
>>>> this
>>>> >>> should be Integer (and hence Integer cell).
>>>> >>>
>>>> >>> Without the custom header (and forcing user to select parameter) we
>>>> >>> cannot decide what type of cell we need in second column.
>>>> >>>
>>>> >>> Let me know your opinion on this.
>>>> >>
>>>> >>
>>>> >> We need to figure out a way to fix it. Our difficulties encountered
>>>> >> writing code should not dictate usability compromises.
>>>> >>
>>>> >> In this case, something that needs some thought and maybe some
>>>> tricky code
>>>> >> has caused us to create an inconsistent UI workflow to side-step the
>>>> >> problem, which is not appropriate as it leads to a poor look and
>>>> feel and
>>>> >> potentially confusion for the user.
>>>> >
>>>> > Agree - we should handle these cases gracefully.
>>>> > We need to over come the limitation by brain storming, which we
>>>> already
>>>> > started offline. :-)
>>>> >
>>>> > To be honest - it is a time consuming work, and there is no quick fix
>>>> for
>>>> > this.
>>>> > We can handle it as one case for each change instead of targeting all
>>>> UI
>>>> > changes as one whole problem.
>>>> > And, we can utilize the same time to fix a lot more cases in beta 2.
>>>>
>>>> As far as I'm aware, this is the only case where there's a real problem.
>>>>
>>>> > I can ask Harshal to find out all possible places, where the similar
>>>> changes
>>>> > are required, and create a separate case for each (though - not
>>>> without your
>>>> > agreement).
>>>>
>>>> I don't think we need to. This one sub-node grid (parameters) is the
>>>> only one that I've seen where we deviate from the intended design -
>>>> and I think I've seen them all now!
>>>>
>>> Hmm..
>>>
>>> Unfortunately - some set of columns needs to be unique in most of the
>>> cases (where these controls are used), and the checks for the unique
>>> dataset is done at the control side, which was wrong at our

Re: [pgadmin-hackers] PATCH: Fix the issue for saving query output as CSV

2016-07-13 Thread Harshal Dhumal
Hi,

PFA rebased patch for RM1405

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jul 13, 2016 at 5:15 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Yes sure
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jul 13, 2016 at 5:10 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Hi
>>
>> Can you rebase this please?
>>
>> Thanks.
>>
>> On Mon, Jul 11, 2016 at 9:16 AM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patch for RM1405. Also to allow download in runtime we will still
>>> need patch
>>> <https://www.postgresql.org/message-id/CACCA4P3JOe40WYMGjhpSWYGR%3DWuvRbbp2gfDKLnU%2B1rXuW9Www%40mail.gmail.com>
>>> sent by Neel.
>>>
>>> Changes: To download query result to CSV directly from server and not to
>>> use download attr. of anchor tag () as it's not support by all of major
>>> browsers (e.g. Safari).
>>> Also it's not feasible to load data in html to download if result set of
>>> query is very huge (in GBs).
>>>
>>>
>>>
>>>
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Wed, Jun 29, 2016 at 4:53 PM, Akshay Joshi <
>>> akshay.jo...@enterprisedb.com> wrote:
>>>
>>>>
>>>>
>>>> On Wed, Jun 29, 2016 at 3:52 PM, Murtuza Zabuawala <murtuza.zabuawala@
>>>> enterprisedb.com> wrote:
>>>>
>>>>> Yes, It will not work in runtime as well but I think Neel is working
>>>>> for fix in run time for this issue, We might able to fix it in run time 
>>>>> but
>>>>> issue persists in Safari unless they add support in browser itself.
>>>>>
>>>>> https://webkit.org/status/#feature-download-attribute
>>>>>
>>>>>
>>>>> > On 29-Jun-2016, at 3:40 pm, Dave Page <dp...@pgadmin.org> wrote:
>>>>> >
>>>>> > On Tue, Jun 28, 2016 at 10:33 AM, Murtuza Zabuawala
>>>>> > <murtuza.zabuaw...@enterprisedb.com> wrote:
>>>>> >> Yes Dave, I agree that downloading files has been supported in
>>>>> browsers since long .
>>>>> >>
>>>>> >> But in general we send request & then receives files from web
>>>>> server but in our case we are fetching our data from Backbone models & 
>>>>> then
>>>>> converting it to CSV format for downloading as a file at client side in
>>>>> browser itself.
>>>>> >
>>>>> > If Safari doesn't support client-side saving of files, then I have to
>>>>> > wonder if our runtime will either - both are webkit based.
>>>>> >
>>>>> > So I guess the next question to ask is; why don't we just generate
>>>>> the
>>>>> > CSV on the server side?
>>>>> >
>>>>>
>>>>> @Akshay,
>>>>> Can you please suggest on above?
>>>>>
>>>>
>>>>As we already have complete data in backgrid's full collection, so
>>>> I have used it instead of fetching it again.
>>>>
>>>>>
>>>>> > --
>>>>> > Dave Page
>>>>> > Blog: http://pgsnake.blogspot.com
>>>>> > Twitter: @pgsnake
>>>>> >
>>>>> > EnterpriseDB UK: http://www.enterprisedb.com
>>>>> > The Enterprise PostgreSQL Company
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>>>> To make changes to your subscription:
>>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> *Akshay Joshi*
>>>> *Principal Software Engineer *
>>>>
>>>>
>>>>
>>>> *Phone: +91 20-3058-9517 <%2B91%2020-3058-9517>Mobile: +91 976-788-8246*
>>>>
>>>
>>>
>>
>>
>> --
>&

Re: [pgadmin-hackers] PATCH: Fix the issue for saving query output as CSV

2016-07-13 Thread Harshal Dhumal
Yes sure

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jul 13, 2016 at 5:10 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> Can you rebase this please?
>
> Thanks.
>
> On Mon, Jul 11, 2016 at 9:16 AM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for RM1405. Also to allow download in runtime we will still
>> need patch
>> <https://www.postgresql.org/message-id/CACCA4P3JOe40WYMGjhpSWYGR%3DWuvRbbp2gfDKLnU%2B1rXuW9Www%40mail.gmail.com>
>> sent by Neel.
>>
>> Changes: To download query result to CSV directly from server and not to
>> use download attr. of anchor tag () as it's not support by all of major
>> browsers (e.g. Safari).
>> Also it's not feasible to load data in html to download if result set of
>> query is very huge (in GBs).
>>
>>
>>
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Wed, Jun 29, 2016 at 4:53 PM, Akshay Joshi <
>> akshay.jo...@enterprisedb.com> wrote:
>>
>>>
>>>
>>> On Wed, Jun 29, 2016 at 3:52 PM, Murtuza Zabuawala <murtuza.zabuawala@
>>> enterprisedb.com> wrote:
>>>
>>>> Yes, It will not work in runtime as well but I think Neel is working
>>>> for fix in run time for this issue, We might able to fix it in run time but
>>>> issue persists in Safari unless they add support in browser itself.
>>>>
>>>> https://webkit.org/status/#feature-download-attribute
>>>>
>>>>
>>>> > On 29-Jun-2016, at 3:40 pm, Dave Page <dp...@pgadmin.org> wrote:
>>>> >
>>>> > On Tue, Jun 28, 2016 at 10:33 AM, Murtuza Zabuawala
>>>> > <murtuza.zabuaw...@enterprisedb.com> wrote:
>>>> >> Yes Dave, I agree that downloading files has been supported in
>>>> browsers since long .
>>>> >>
>>>> >> But in general we send request & then receives files from web server
>>>> but in our case we are fetching our data from Backbone models & then
>>>> converting it to CSV format for downloading as a file at client side in
>>>> browser itself.
>>>> >
>>>> > If Safari doesn't support client-side saving of files, then I have to
>>>> > wonder if our runtime will either - both are webkit based.
>>>> >
>>>> > So I guess the next question to ask is; why don't we just generate the
>>>> > CSV on the server side?
>>>> >
>>>>
>>>> @Akshay,
>>>> Can you please suggest on above?
>>>>
>>>
>>>As we already have complete data in backgrid's full collection, so I
>>> have used it instead of fetching it again.
>>>
>>>>
>>>> > --
>>>> > Dave Page
>>>> > Blog: http://pgsnake.blogspot.com
>>>> > Twitter: @pgsnake
>>>> >
>>>> > EnterpriseDB UK: http://www.enterprisedb.com
>>>> > The Enterprise PostgreSQL Company
>>>>
>>>>
>>>>
>>>> --
>>>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>>>
>>>
>>>
>>>
>>> --
>>> *Akshay Joshi*
>>> *Principal Software Engineer *
>>>
>>>
>>>
>>> *Phone: +91 20-3058-9517 <%2B91%2020-3058-9517>Mobile: +91 976-788-8246*
>>>
>>
>>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] PATCH: Fix the issue for saving query output as CSV

2016-07-11 Thread Harshal Dhumal
Hi,

PFA patch for RM1405. Also to allow download in runtime we will still need
patch
<https://www.postgresql.org/message-id/CACCA4P3JOe40WYMGjhpSWYGR%3DWuvRbbp2gfDKLnU%2B1rXuW9Www%40mail.gmail.com>
sent by Neel.

Changes: To download query result to CSV directly from server and not to
use download attr. of anchor tag () as it's not support by all of major
browsers (e.g. Safari).
Also it's not feasible to load data in html to download if result set of
query is very huge (in GBs).





-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jun 29, 2016 at 4:53 PM, Akshay Joshi <akshay.jo...@enterprisedb.com
> wrote:

>
>
> On Wed, Jun 29, 2016 at 3:52 PM, Murtuza Zabuawala <murtuza.zabuawala@
> enterprisedb.com> wrote:
>
>> Yes, It will not work in runtime as well but I think Neel is working for
>> fix in run time for this issue, We might able to fix it in run time but
>> issue persists in Safari unless they add support in browser itself.
>>
>> https://webkit.org/status/#feature-download-attribute
>>
>>
>> > On 29-Jun-2016, at 3:40 pm, Dave Page <dp...@pgadmin.org> wrote:
>> >
>> > On Tue, Jun 28, 2016 at 10:33 AM, Murtuza Zabuawala
>> > <murtuza.zabuaw...@enterprisedb.com> wrote:
>> >> Yes Dave, I agree that downloading files has been supported in
>> browsers since long .
>> >>
>> >> But in general we send request & then receives files from web server
>> but in our case we are fetching our data from Backbone models & then
>> converting it to CSV format for downloading as a file at client side in
>> browser itself.
>> >
>> > If Safari doesn't support client-side saving of files, then I have to
>> > wonder if our runtime will either - both are webkit based.
>> >
>> > So I guess the next question to ask is; why don't we just generate the
>> > CSV on the server side?
>> >
>>
>> @Akshay,
>> Can you please suggest on above?
>>
>
>As we already have complete data in backgrid's full collection, so I
> have used it instead of fetching it again.
>
>>
>> > --
>> > Dave Page
>> > Blog: http://pgsnake.blogspot.com
>> > Twitter: @pgsnake
>> >
>> > EnterpriseDB UK: http://www.enterprisedb.com
>> > The Enterprise PostgreSQL Company
>>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>
>
>
> --
> *Akshay Joshi*
> *Principal Software Engineer *
>
>
>
> *Phone: +91 20-3058-9517Mobile: +91 976-788-8246*
>
diff --git a/web/pgadmin/tools/datagrid/templates/datagrid/index.html b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
index b138a46..fc918c4 100644
--- a/web/pgadmin/tools/datagrid/templates/datagrid/index.html
+++ b/web/pgadmin/tools/datagrid/templates/datagrid/index.html
@@ -181,6 +181,7 @@
 
 
 
+
 
 
 {% endblock %}
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index c713fb5..48fd0ba 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -28,6 +28,7 @@ from pgadmin.utils.sqlautocomplete.autocomplete import SQLAutoComplete
 
 from config import PG_DEFAULT_DRIVER
 
+
 # import unquote from urlib for python2.x and python3.x
 try:
 from urllib import unquote
@@ -1212,3 +1213,58 @@ def save_file():
 'status': True,
 }
 )
+
+
+@blueprint.route('/query_tool/download/', methods=["GET"])
+@login_required
+def start_query_download_tool(trans_id):
+sync_conn = None
+status, error_msg, conn, trans_obj, session_obj = check_transaction_status(trans_id)
+
+if status and conn is not None \
+and trans_obj is not None and session_obj is not None:
+
+data = request.args if request.args else None
+try:
+if data and 'query' in data:
+sql = data['query']
+conn_id = str(random.randint(1, 999))
+sync_conn = conn.manager.connection(
+did=trans_obj.did,
+conn_id=conn_id,
+auto_reconnect=False,
+async=False
+)
+
+sync_conn.connect(autocommit=False)
+
+# This returns generator of records.
+status, gen = sync_conn.execute_on_server_as_csv(sql, records=2000)
+
+if not status:
+conn.manager.release(conn_id=conn_id, did=trans_obj.di

Re: [pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-07 Thread Harshal Dhumal
Hi,

By mistake I deleted a line which was not supposed to be deleted, and that
line of code was initialization of select2.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jul 7, 2016 at 12:13 PM, Ashesh Vashi <ashesh.va...@enterprisedb.com
> wrote:

> Hi Harshal,
>
> Can you please explain - what was missing in the last patch?
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> <http://www.enterprisedb.com>
>
>
> *http://www.linkedin.com/in/asheshvashi*
> <http://www.linkedin.com/in/asheshvashi>
>
> On Thu, Jul 7, 2016 at 12:12 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA updated patch for issue RM1260
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>> On Thu, Jul 7, 2016 at 12:04 PM, Harshal Dhumal <
>> harshal.dhu...@enterprisedb.com> wrote:
>>
>>> Hi,
>>> Please ignore this patch as this has some minor issue. I'll sent updated
>>> one.
>>>
>>> --
>>> *Harshal Dhumal*
>>> *Software Engineer*
>>>
>>> EnterpriseDB India: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>> On Wed, Jul 6, 2016 at 5:30 PM, Harshal Dhumal <
>>> harshal.dhu...@enterprisedb.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> PFA patch for issue RM1260.
>>>>
>>>> Changes: Issue wasn't related to foreign table but was due the Select2
>>>> control. Now I have improved select2 control to handle null value in
>>>> multi-select mode. Initial it was returning "null" instead it should return
>>>> [] (empty array).
>>>>
>>>>
>>>> --
>>>> *Harshal Dhumal*
>>>> *Software Engineer*
>>>>
>>>> EnterpriseDB India: http://www.enterprisedb.com
>>>> The Enterprise PostgreSQL Company
>>>>
>>>
>>>
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>>
>


Re: [pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-07 Thread Harshal Dhumal
Hi,

PFA updated patch for issue RM1260

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jul 7, 2016 at 12:04 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
> Please ignore this patch as this has some minor issue. I'll sent updated
> one.
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Wed, Jul 6, 2016 at 5:30 PM, Harshal Dhumal <
> harshal.dhu...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> PFA patch for issue RM1260.
>>
>> Changes: Issue wasn't related to foreign table but was due the Select2
>> control. Now I have improved select2 control to handle null value in
>> multi-select mode. Initial it was returning "null" instead it should return
>> [] (empty array).
>>
>>
>> --
>> *Harshal Dhumal*
>> *Software Engineer*
>>
>> EnterpriseDB India: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
index a4b5a27..3af6c61 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
@@ -266,12 +266,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   */
 
   var NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsControl.extend({
-template: _.template([
-  '<%=label%>',
-  '',
-  '   <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> >',
-  '  ',
-  ''].join("\n")),
 defaults: _.extend(
   {}, Backform.NodeAjaxOptionsControl.prototype.defaults,
   {
@@ -335,7 +329,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   {
 'data': data.options
   });
-this.$el.find("select").select2(opts).val(data.rawValue).trigger("change");
+this.$el.find("select").select2(opts);
 this.updateInvalid();
 }
   }
@@ -370,7 +364,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 
   // Remove Columns if inherit option is deselected from the combobox
   if(_.size(value) < _.size(inherits)) {
-var dif =  _.difference(inherits, JSON.parse(value));
+var dif =  _.difference(inherits, value);
 var rmv_columns = columns.where({inheritedid: parseInt(dif[0])});
 columns.remove(rmv_columns);
   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
index 83445a2..1bb501e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
@@ -9,7 +9,7 @@ WHERE
 
 {% else %}
 SELECT
-c.oid AS id, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as text
+c.oid AS value, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as label
 FROM
 pg_class c, pg_namespace n
 WHERE
@@ -19,4 +19,4 @@ WHERE
 {% endif %}
 ORDER BY
 n.nspname, c.relname;
-{% endif %}
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 973b60b..fb6c51f 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1793,7 +1793,11 @@
   if (_.isArray(formattedData)) {
 return _.map(formattedData, decodeURIComponent);
   } else {
-return decodeURIComponent(formattedData);
+if(!_.isNull(formattedData) && !_.isUndefined(formattedData)) {
+  return decodeURIComponent(formattedData);
+} else {
+  return null;
+}
   }
 }
   });
@@ -1904,9 +1908,15 @@
   return this;
 },
 getValueFromDOM: function() {
-  return Backform.SelectControl.prototype.getValueFromDOM.apply(
-this, arguments
-  );
+  var val = Backform.SelectControl.prototype.getValueFromDOM.apply(
+  this, arguments
+),
+select2Opts = _.extend({}, thi

[pgadmin-hackers] patch for issue RM1260 [pgAdmin4]

2016-07-06 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1260.

Changes: Issue wasn't related to foreign table but was due the Select2
control. Now I have improved select2 control to handle null value in
multi-select mode. Initial it was returning "null" instead it should return
[] (empty array).


-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
index a4b5a27..26418a6 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/js/foreign_tables.js
@@ -266,12 +266,6 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
   */
 
   var NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsMultipleControl = Backform.NodeAjaxOptionsControl.extend({
-template: _.template([
-  '<%=label%>',
-  '',
-  '   <%=disabled ? "disabled" : ""%> <%=required ? "required" : ""%> >',
-  '  ',
-  ''].join("\n")),
 defaults: _.extend(
   {}, Backform.NodeAjaxOptionsControl.prototype.defaults,
   {
@@ -331,11 +325,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 this.$el.addClass(Backform.hiddenClassname);
 } else {
 var opts = _.extend(
-  {}, this.defaults.select2, data.select2,
-  {
-'data': data.options
-  });
-this.$el.find("select").select2(opts).val(data.rawValue).trigger("change");
+  {}, this.defaults.select2, data.select2);
 this.updateInvalid();
 }
   }
@@ -370,7 +360,7 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 
   // Remove Columns if inherit option is deselected from the combobox
   if(_.size(value) < _.size(inherits)) {
-var dif =  _.difference(inherits, JSON.parse(value));
+var dif =  _.difference(inherits, value);
 var rmv_columns = columns.where({inheritedid: parseInt(dif[0])});
 columns.remove(rmv_columns);
   }
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
index 83445a2..1bb501e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/get_tables.sql
@@ -9,7 +9,7 @@ WHERE
 
 {% else %}
 SELECT
-c.oid AS id, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as text
+c.oid AS value, quote_ident(n.nspname) || '.' || quote_ident(c.relname) as label
 FROM
 pg_class c, pg_namespace n
 WHERE
@@ -19,4 +19,4 @@ WHERE
 {% endif %}
 ORDER BY
 n.nspname, c.relname;
-{% endif %}
+{% endif %}
\ No newline at end of file
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 973b60b..fb6c51f 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1793,7 +1793,11 @@
   if (_.isArray(formattedData)) {
 return _.map(formattedData, decodeURIComponent);
   } else {
-return decodeURIComponent(formattedData);
+if(!_.isNull(formattedData) && !_.isUndefined(formattedData)) {
+  return decodeURIComponent(formattedData);
+} else {
+  return null;
+}
   }
 }
   });
@@ -1904,9 +1908,15 @@
   return this;
 },
 getValueFromDOM: function() {
-  return Backform.SelectControl.prototype.getValueFromDOM.apply(
-this, arguments
-  );
+  var val = Backform.SelectControl.prototype.getValueFromDOM.apply(
+  this, arguments
+),
+select2Opts = _.extend({}, this.field.get("select2") || this.defaults.select2);
+
+  if (select2Opts.multiple && val == null) {
+return [];
+  }
+  return val;
 }
   });
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] patch for issue RM1418 and RM1434 [pgadmin4]

2016-07-05 Thread Harshal Dhumal
Hi,

PFA patch for Issue RM1418 and RM1434

Issues fixed: 1. Select2 control fixed for multi-select mode.
2. Index constrains (primary and unique key) fixed column listing issue.
3. Table node "inherited from" (Select2 control) was not showing table name
with public schema

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
index 1e45cad..73a563b 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/constraints/index_constraint/templates/index_constraint/js/index_constraint.js
@@ -227,6 +227,20 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
 }
   }
 ),
+keyPathAccessor: function(obj, path) {
+  var res = obj;
+  if(_.isArray(res)) {
+return _.map(res, function(o) { return o['column']
+});
+  }
+  path = path.split('.');
+  for (var i = 0; i < path.length; i++) {
+if (_.isNull(res)) return null;
+if (_.isEmpty(path[i])) continue;
+if (!_.isUndefined(res[path[i]])) res = res[path[i]];
+  }
+  return _.isObject(res) && !_.isArray(res) ? null : res;
+},
 initialize: function() {
 // Here we will decide if we need to call URL
 // Or fetch the data from parent columns collection
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
index 99727c9..2f53a2e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/properties.sql
@@ -8,7 +8,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 			JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
 			WHERE tgrelid=rel.oid) AS isrepl,
 	(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
-	(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%' AND nspname <> 'public') THEN
+	(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
 quote_ident(nspname)||'.'||quote_ident(c.relname)
 ELSE quote_ident(c.relname) END AS inherited_tables
 FROM pg_inherits i
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
index 99727c9..2f53a2e 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/properties.sql
@@ -8,7 +8,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r
 			JOIN pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
 			WHERE tgrelid=rel.oid) AS isrepl,
 	(SELECT count(*) FROM pg_trigger WHERE tgrelid=rel.oid AND tgisinternal = FALSE) AS triggercount,
-	(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%' AND nspname <> 'public') THEN
+	(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE E'pg\_%') THEN
 quote_ident(nspname)||'.'||quote_ident(c.relname)
 ELSE quote_ident(c.relname) END AS inherited_tables
 FROM pg_inherits i
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 1370698..973b60b 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1790,7 +1790,11 @@
   return encodeURIComponent(rawData);
 },
 toRaw: function(formattedData, model) {
-  return decodeURIComponent(formattedData);
+  if (_.isArray(formattedData)) {
+return _.map(formattedData, decodeURIComponent);
+  } else {
+return decodeURIComponent(formattedData);
+  }
 }
   });
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Re: [pgAdmin 4 - Bug #1292] ERROR: template database "!@#$%^&*()_+{}|:"<>?=-\\][';/.," does not exist message throws if template database contain special charterers

2016-07-05 Thread Harshal Dhumal
Hi,


This patch has caused another new issue (or regression).

Issue: Select2 control does not work in multi-select mode.

Node affected due to this are Primary key, unique key, and all other node
where we have used select2 control in multi-select mode.

Commit id:   4267545e08cb28b8c4574bb7a5da0322ef7728d2







-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Jun 24, 2016 at 4:54 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch to fix the issue RM#1292.
>
> Earlier patch was not handling spaces properly.
> e.g- If user creates any objects which has spaces in its name then it
> fails to parse it next time user select it.
>
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Mon, Jun 20, 2016 at 8:34 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> Thanks, patch applied.
>>
>> On Mon, Jun 20, 2016 at 2:56 PM, Sanket Mehta
>> <sanket.me...@enterprisedb.com> wrote:
>> > Hi,
>> >
>> > PFA the revised patch to resolve this issue which consists the change in
>> > control formatter.
>> >
>> >
>> > Regards,
>> > Sanket Mehta
>> > Sr Software engineer
>> > Enterprisedb
>> >
>> > On Mon, Jun 13, 2016 at 3:12 PM, <redm...@postgresql.org> wrote:
>> >>
>> >> Issue #1292 has been updated by Dave Page.
>> >>
>> >> Target version deleted (1.0 Beta 1)
>> >>
>> >> 
>> >>
>> >> Bug #1292: ERROR: template database "!@#$%^&*()_+{}|:"<>?=-\\][';/.,"
>> does
>> >> not exist message throws if template database contain special
>> charterers
>> >>
>> >> Author: Fahar Abbas
>> >> Status: In Progress
>> >> Priority: Normal
>> >> Assignee: Sanket Mehta
>> >> Category:
>> >> Target version:
>> >>
>> >> Commit ID:
>> >> ---
>> >> commit 954163b4957c1dce89c0632d009b845cbe90faf4
>> >>
>> >> Browser version:
>> >> 
>> >> Firefox 45.0.2
>> >>
>> >> Python version:
>> >> 
>> >> 3.5.1+
>> >>
>> >> Platforms:
>> >> All
>> >>
>> >> ERROR: template database "!@#$%^&*()_+{}|:"<>?=-\\][';/.," does not
>> exist
>> >> message throws if user try to create database with template database
>> that
>> >> name contain special charterers.
>> >>
>> >> Please note that this issue is not reproducible in other template
>> >> databases that name is simple one.
>> >>
>> >> Please note that this is not reproduce in pgAdmin3.
>> >>
>> >> Steps:
>> >>
>> >> 1. Install pgAdmin4 on Ubuntu 16.04
>> >> 2. Install PG-9.6-beta 1 installer
>> >> 3. Expand database node
>> >> 4. give it's name !#$%^&*()_+{}|:"<>?=-\][';/.,
>> >> 5. Database created successfully
>> >> 6. Again create new database and give it's name abcd
>> >> 7. Click on definition tab
>> >> 8. select template database !#$%^&*()_+{}|:"<>?=-\][';/.,
>> >> 9. Click on Save button
>> >>
>> >> Files Screen Shot 2016-06-02 at 10.25.34 am.png (1020 KB)
>> >> Screen Shot 2016-06-02 at 10.26.01 am.png (1.03 MB)
>> >> 
>> >>
>> >> You have received this notification because you have either subscribed
>> to
>> >> it, or are involved in it.
>> >> To change your notification preferences, please click here:
>> >> https://redmine.postgresql.org/my/account
>> >
>> >
>> >
>> >
>> > --
>> > Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> > To make changes to your subscription:
>> > http://www.postgresql.org/mailpref/pgadmin-hackers
>> >
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>>
>> --
>> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgadmin-hackers
>>
>
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
>


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-07-04 Thread Harshal Dhumal
Hi,

PFA updated patch for RM1336 and keyboard shortcuts file separately.

This patch is same as last patch except I have removed keyboard shortcut
list from this patch.

Also please see my inline response below.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Fri, Jul 1, 2016 at 5:46 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Fri, Jul 1, 2016 at 11:10 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA patch
> >
> > This contains:
> > 1] All shortcuts' list which we are using in pgAdmin4.
> > 2] Fixed shortcut display tooltips.
> >
> >
> > --
> > Harshal Dhumal
> > Software Engineer
> >
> > EnterpriseDB India: http://www.enterprisedb.com
> > The Enterprise PostgreSQL Company
> >
> > On Thu, Jun 30, 2016 at 2:34 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> Hi Harshal,
> >>
> >> On Thu, Jun 30, 2016 at 7:59 AM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi Dave,
> >> >
> >> > Somehow control key is mapped to Command key in Mac. So on Mac
> shortcuts
> >> > are
> >> > Shift+Command+E, Shift+Command+X, Shift+Command+A
> >>
> >> OK, those work, but I think we need to take a step back here (partly
> >> because Cmd+Shift+A seems to be Select All in CodeMirror on Mac). I've
> >> committed the patch now, but changed Ctrl+Shift+A to Ctrl+Shift+N.
> >>
> >> Can you please work on the following:
> >>
> >> 1) Create a table of shortcuts from our runtime, our web app, and
> >> CodeMirror. This should list:
> >>
> >> Component (e.g. runtime, CodeMirror, Query Tool)
> >> Standard shortcut (e.g. Ctrl+Shift+A)
> >> Mac shortcut (e.g. Cmd+Shift+A)
> >> Function (e.g. Explain Analyze or Select All)
> >>
> >> Let's make this as complete and accurate as possible, so it can be
> >> included in the documentation, and used by us to select or
> >> de-duplicate shortcuts.
> >
> > Added shortcuts' list.
>
> Let's keep it as a separate file for now, and not part of the source
> tree or any patches.
>
> I notice that it's missing much of what I wanted to collect though, e.g.
>
> Ctrl+Space - Autocomplete(?)
> Cut
> Copy
> Paste
> Select All
> ...
>

The other CodeMirror keys can be found at
> https://codemirror.net/doc/manual.html#keymaps. Please add at least
> the basic editting commands.
>
Yes I have added basic codemirror shortcuts in file.



>
> >> 2) Confirm that the shortcuts we're using in our runtime and web
> >> application don't conflict with any in CodeMirror (or web browsers, in
> >> the case of the web app).
> >
> > Tested. No other conflicting shortcuts found.
>
> Good.
>
> >>
> >> 3) Update the web application so the shortcuts are correctly displayed
> >> on Mac automatically - e.g. the tooltips and menus should show
> >> Cmd+Shift not Ctrl+Shift
> >
> > Fixed
> >
> >>
> >>
> >> 4) Investigate #1360, and ensure that the CodeMirror shortcuts work
> >> consistently between the runtime and browsers on all platforms.
> >
> > Investigating now.
>
> You've already found one inconsistency - Cmd vs. Ctrl on Mac browsers
> vs. the runtime. It should be Cmd in either UI, to avoid user
> confusion.
>
Yes, UI will now show Ctrl or Cmd depending on os platform and application
mode (web/runtime). (This was also there in last patch)



> >>
> >> 5) Investigate any remaining shortcuts that don't work as expected.
> >
> >
> > Investigating now.: Codemirror shortcut (Cmd/Ctrl+Shift+A)  "Select all"
> > only works on Mac (web/runtime) not on linux platform (haven't tested on
> > windows)
>
"Select all" was working on linux as well. It was my mistake. I have added
shortcut key details in keyboard shortcut file.



>
> Yeah - see also some of the comments I made on
> https://redmine.postgresql.org/issues/1360
>
> I spend some time debugging this but didn't get what's going wrong here.


> Let's figure out what's wrong first, then come up with a set of
> fixes/changes that will get us to a consistent set of keys that work
> as per the list you're preparing.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
+-

Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-07-01 Thread Harshal Dhumal
Hi,

PFA patch

This contains:
1] All shortcuts' list which we are using in pgAdmin4.
2] Fixed shortcut display tooltips.


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 30, 2016 at 2:34 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi Harshal,
>
> On Thu, Jun 30, 2016 at 7:59 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi Dave,
> >
> > Somehow control key is mapped to Command key in Mac. So on Mac shortcuts
> are
> > Shift+Command+E, Shift+Command+X, Shift+Command+A
>
> OK, those work, but I think we need to take a step back here (partly
> because Cmd+Shift+A seems to be Select All in CodeMirror on Mac). I've
> committed the patch now, but changed Ctrl+Shift+A to Ctrl+Shift+N.
>
> Can you please work on the following:
>
> 1) Create a table of shortcuts from our runtime, our web app, and
> CodeMirror. This should list:
>
> Component (e.g. runtime, CodeMirror, Query Tool)
> Standard shortcut (e.g. Ctrl+Shift+A)
> Mac shortcut (e.g. Cmd+Shift+A)
> Function (e.g. Explain Analyze or Select All)
>
> Let's make this as complete and accurate as possible, so it can be
> included in the documentation, and used by us to select or
> de-duplicate shortcuts.
>
Added shortcuts' list.


>
> 2) Confirm that the shortcuts we're using in our runtime and web
> application don't conflict with any in CodeMirror (or web browsers, in
> the case of the web app).
>
Tested. No other conflicting shortcuts found.


>
> 3) Update the web application so the shortcuts are correctly displayed
> on Mac automatically - e.g. the tooltips and menus should show
> Cmd+Shift not Ctrl+Shift
>
Fixed


>
> 4) Investigate #1360, and ensure that the CodeMirror shortcuts work
> consistently between the runtime and browsers on all platforms.
>
Investigating now.


>
> 5) Investigate any remaining shortcuts that don't work as expected.
>

Investigating now.: Codemirror shortcut (Cmd/Ctrl+Shift+A)  "Select all"
only works on Mac (web/runtime) not on linux platform (haven't tested on
windows)

>
> Thanks, Dave.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/keyboard_shortcuts.txt b/web/keyboard_shortcuts.txt
new file mode 100644
index 000..1684dc0
--- /dev/null
+++ b/web/keyboard_shortcuts.txt
@@ -0,0 +1,28 @@
+++
+|   pgAdmin4 keyboard shortcuts  |
+++
+==
+
+
+
++-+---+---+--+
+| Component   | Function  | Standard shortcut | Mac shortcut |
++-+---+---+--+
+| | Open Url  | Alt+Shift+U   | Alt+Shift+U  |
+| +---+---+--+
+| pgAdmin4 runtime| Set python path   | Alt+Shift+P   | Alt+Shift+P  |
+| +---+---+--+
+| | Open about dialog | Alt+Shift+A   | Alt+Shift+A  |
++-+---+---+--+
+| | Execute query | Ctrl+Shift+E  | Cmd+Shift+E (runtime)|
+| |   |   | Ctrl+Shift+E (web)   |
+| +---+---+--+
+| Query tool  | Explain   | Ctrl+Shift+X  | Cmd+Shift+X (runtime)|
+| |   |   | Ctrl+Shift+X (web)   |
+| +---+---+--+
+| | Explain analyze   | Ctrl+Shift+N  | Cmd+Shift+N (runtime)|
+| |   |   | Ctrl+Shift+N (web)   |
++-+---+---+--+
+| Codemirror  | Select all text   |   | Cmd+Shift+A (runtime)|
+| (query editor)  | in editor |   | Ctrl+Shift+A (web)   |
++-+---+---+--+
diff --git a/web/pgadmin/tools/datagrid/__init__.py b/web/pgadmin/tools/datagrid/__init__.py
index 3a7625f..3580638 100644
--- a/web/pgadmin/tools/datagrid/__init__.py
+++ b/web/pgadmin/tools/datagrid/__init__.py
@@ -23,7 +23,7 @@ from pgad

[pgadmin-hackers] fix for issue rm1425 [pgAdmin4]

2016-07-01 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1425.

Issue fixed: Loading panel does not hide in Mac runtime due error in js.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html
index 7ceda69..12f01a3 100644
--- a/web/pgadmin/browser/templates/browser/index.html
+++ b/web/pgadmin/browser/templates/browser/index.html
@@ -30,7 +30,7 @@ require.onResourceLoad = function (context, map, depMaps) {
   // is not loading anything hide the indicator and exit
   setTimeout(function() {
 if (panel != null) {
-  panel.remove();
+  $(panel).remove();
   return;
 }
   }, 500);

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-30 Thread Harshal Dhumal
Hi Dave,

Somehow control key is mapped to Command key in Mac. So on Mac shortcuts
are Shift+Command+E, Shift+Command+X, Shift+Command+A

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 30, 2016 at 1:05 AM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Wed, Jun 29, 2016 at 7:32 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > Here is updated patch for RM1336
> >
> > Fixed query tool shortcuts issue in Mac runtime and changed shortcut to
> show
> > "About" dialog in runtime from Ctrl+Shift+A > Alt+Shift+A
>
> I updated the runtime to use Alt+Shift+A, as well as changing the
> other shortcuts to use Alt+Shift to avoid future collisions.
>
> However, the shortcuts in the app still don't work in the runtime for
> me, so I haven't applied the other change.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-29 Thread Harshal Dhumal
Hi,

Here is updated patch for RM1336

Fixed query tool shortcuts issue in Mac runtime and changed shortcut to
show "About" dialog in runtime from Ctrl+Shift+A > Alt+Shift+A

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Wed, Jun 29, 2016 at 11:41 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Wed, Jun 29, 2016 at 7:05 PM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA upadated patch for RM1336
> >
> > Issue fixed: Query tool shortcuts weren't working on mac runtime. Also
> > changed shortcut key for "Explain analyze" from Ctrl+Shift+A --->
> > Alt+Shift+N as Ctrl+Shift+A was conflicting with shortcut to show "about"
> > dialog in runtime.
>
> Thanks - but let's change the runtime and go back to Ctrl+Shift+A in
> the app. The About box in the runtime is really unimportant.
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/runtime/BrowserWindow.cpp b/runtime/BrowserWindow.cpp
index 5419c0e..684cb27 100644
--- a/runtime/BrowserWindow.cpp
+++ b/runtime/BrowserWindow.cpp
@@ -125,7 +125,7 @@ void BrowserWindow::createActions()
 connect(exitShortcut, SIGNAL(activated()), this, SLOT(close()));
 
 // About box
-aboutShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_A), this);
+aboutShortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::SHIFT + Qt::Key_A), this);
 aboutShortcut->setContext(Qt::ApplicationShortcut);
 connect(aboutShortcut, SIGNAL(activated()), this, SLOT(about()));
 }
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 92579f1..2a269c0 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -176,7 +176,7 @@ define(
 "click #btn-explain-buffers": "on_explain_buffers",
 "click #btn-explain-timing": "on_explain_timing",
 "change .limit": "on_limit_change",
-"keyup": "keyAction"
+"keydown": "keyAction"
   },
 
   // This function is used to render the template.
@@ -1020,7 +1020,7 @@ define(
 // char e/E
 // Execute query.
 this.on_flash(ev);
-  } else if(ev.keyCode == 88){
+  } else if(ev.keyCode == 88) {
 // char x/X
 // Explain query.
 this.on_explain(ev);

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-29 Thread Harshal Dhumal
Hi,

PFA upadated patch for RM1336

Issue fixed: Query tool shortcuts weren't working on mac runtime. Also
changed shortcut key for "Explain analyze" from Ctrl+Shift+A --->
Alt+Shift+N as Ctrl+Shift+A was conflicting with shortcut to show "about"
dialog in runtime.



-- 
*Harshal Dhumal*
*Software Engineer*

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

On Mon, Jun 20, 2016 at 7:30 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Mon, Jun 20, 2016 at 2:51 PM, Colin Beckingham <col...@kingston.net>
> wrote:
> >
> > On 20/06/16 09:33, Dave Page wrote:
> >>
> >> It's not that it's necessarily hard, it's that there are only 24 hours
> in
> >> the day to get things done. We've got a long list of improvements to
> make -
> >> some immediate (i.e. in time for betaX - 2 being today in fact), others
> for
> >> GA and others for future releases. Meanwhile, much as I'd like to, I
> cannot
> >> keep 10 people assigned to pgAdmin indefinitely. I do need to get them
> >> working on other projects, for which there are also deadlines.
> >
> > Since pgadmin4 is at the top of the stack browser - window environment -
> OS
> > - kernel, all of which have their call on some specific set of
> shortcuts, a
> > couple of thoughts:
> > 1. are there other applications similar to pgadmin which are in the same
> > position where they too are looking for shortcuts? In which case is
> there a
> > possibility of cross-fertilization of ideas?
>
> The only app I've found so far like that is Gmail, but 95% of it's
> shortcuts are single keys that only work when you're not already
> focussed in an editable field. In pgAdmin, that doesn't help much in
> cases like this, when you're likely editing a query.
>
> > 2. in the world of software shortcuts, the needs of dependent
> applications
> > such as pgadmin might not have been foreseen, but is there in the
> hierarchy
> > a moral obligation to keep a certain subset of combinations free? At the
> > moment it seems like a free for all...
>
> Yeah, you'd think there should be some moral obligation, but you're
> right - it is a free for all.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
index 92579f1..4001066 100644
--- a/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/js/sqleditor.js
@@ -1015,19 +1015,23 @@ define(
 
   // Callback for keyboard event
   keyAction: function(ev) {
-if(ev.ctrlKey && ev.shiftKey) {
-  if(ev.keyCode == 69) {
-// char e/E
-// Execute query.
-this.on_flash(ev);
-  } else if(ev.keyCode == 88){
-// char x/X
-// Explain query.
-this.on_explain(ev);
-  } else if(ev.keyCode == 65) {
-// char a/A
-// Explain analyze query.
-this.on_explain_analyze(ev);
+if(ev.shiftKey) {
+  if(ev.ctrlKey) {
+if(ev.keyCode == 69) {
+  // char e/E
+  // Execute query.
+  this.on_flash(ev);
+} else if(ev.keyCode == 88) {
+  // char x/X
+  // Explain query.
+  this.on_explain(ev);
+}
+  } else if(ev.altKey) {
+if(ev.keyCode == 78) {
+  // char n/N
+  // Explain analyze query.
+  this.on_explain_analyze(ev);
+}
   }
 }
   }

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Patch for RM1399 [pGADMIN4]

2016-06-28 Thread Harshal Dhumal
Hi,

PFA patch for issue rm1399

Issue: Sometimes codemirror does not render properly in SQL tab

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/browser/templates/browser/js/browser.js b/web/pgadmin/browser/templates/browser/js/browser.js
index e2242f2..1da37bb 100644
--- a/web/pgadmin/browser/templates/browser/js/browser.js
+++ b/web/pgadmin/browser/templates/browser/js/browser.js
@@ -329,6 +329,10 @@ function(require, $, _, S, Bootstrap, pgAdmin, alertify, CodeMirror) {
 readOnly: true
   });
 
+  setTimeout(function() {
+obj.editor.refresh();
+  }, 10);
+
   // Initialise the treeview
   $('#tree').aciTree({
 ajax: {
diff --git a/web/pgadmin/misc/sql/static/js/sql.js b/web/pgadmin/misc/sql/static/js/sql.js
index 4e13c01..34ab6ff 100644
--- a/web/pgadmin/misc/sql/static/js/sql.js
+++ b/web/pgadmin/misc/sql/static/js/sql.js
@@ -24,7 +24,7 @@ function(_, $, pgBrowser) {
 this.sqlPanelVisibilityChanged
   );
 
-  // Hmm.. Did we find the SQL panel, and is it visible (openned)?
+  // Hmm.. Did we find the SQL panel, and is it visible (opened)?
   // If that is the case - we need to listen the browser tree selection
   // events.
   if (sqlPanels.length == 0) {
@@ -52,9 +52,8 @@ function(_, $, pgBrowser) {
* through. We will wait for some time before fetching the Reversed
* Engineering SQL.
**/
-  if (this.timeout) {
-clearTimeout(this.timeout);
-  }
+  this.timeout && clearTimeout(this.timeout);
+
   this.timeout =  setTimeout(
 function() {
   var sql = '';
@@ -78,10 +77,8 @@ function(_, $, pgBrowser) {
 }
   });
 }
-  } else {
-var e = pgAdmin.Browser.editor;
-e.refresh.apply(e);
   }
+
   if (sql != '') {
 pgAdmin.Browser.editor.setValue(sql);
   }

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-23 Thread Harshal Dhumal
One more thing that this also fails in pgadmin3 as well.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 23, 2016 at 6:26 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi Dave,
>
> It seems that pg_dump utility does not handle database name properly with
> equal to (=) sign in it.
>
> Observe above stack trace, we are generating command line command
> properly. However pg_dump only takes database name upto equal to sign reset
> is ignored.
>
> e.g. Database name in command is *"!#$%^&*()_+{}|:\"<>?=-\\][';/**.,"*
> but in pg_dump error it says *failed: invalid connection option
> "!#$%^&*()_+{}|:"<>?"*
>
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On Thu, Jun 23, 2016 at 4:19 PM, Dave Page <dp...@pgadmin.org> wrote:
>
>> On Wed, Jun 22, 2016 at 11:09 AM, Harshal Dhumal
>> <harshal.dhu...@enterprisedb.com> wrote:
>> > Hi,
>> >
>> > PFA updated patch for issues 1220 and 1221
>>
>> Hi
>>
>> Still not working I'm afraid:
>>
>> Backing up an object on the server 'PostgreSQL 9.4 (127.0.0.1:5432)'
>> from database '!#$%^&*()_+{}|:"<>?=-\][';/.,'...
>> Running command:
>> /Library/PostgreSQL/9.5/bin/pg_dump --file
>> "/Users/dpage/.pgadmin/storage/dpage/foo.sql" --host "127.0.0.1"
>> --port "5432" --username "postgres" --no-password --verbose --format=c
>> --blobs --section=pre-data --section=data --section=post-data
>> "!#$%^&*()_+{}|:\"<>?=-\\][';/.,"
>>
>> Start time: Thu Jun 23 2016 11:49:06 GMT+0100 (BST)
>>
>> pg_dump: [archiver (db)] connection to database "" failed: invalid
>> connection option "!#$%^&*()_+{}|:"<>?"
>> error: [Errno 9] Bad file descriptor
>> r = self.sock.recv(1024)
>> File "/Applications/PyCharm
>> CE.app/Contents/helpers/pydev/pydevd_comm.py", line 329, in OnRun
>> Traceback (most recent call last):
>>
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-23 Thread Harshal Dhumal
Hi Dave,

It seems that pg_dump utility does not handle database name properly with
equal to (=) sign in it.

Observe above stack trace, we are generating command line command properly.
However pg_dump only takes database name upto equal to sign reset is
ignored.

e.g. Database name in command is *"!#$%^&*()_+{}|:\"<>?=-\\][';/**.,"* but
in pg_dump error it says *failed: invalid connection option
"!#$%^&*()_+{}|:"<>?"*


-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 23, 2016 at 4:19 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Wed, Jun 22, 2016 at 11:09 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA updated patch for issues 1220 and 1221
>
> Hi
>
> Still not working I'm afraid:
>
> Backing up an object on the server 'PostgreSQL 9.4 (127.0.0.1:5432)'
> from database '!#$%^&*()_+{}|:"<>?=-\][';/.,'...
> Running command:
> /Library/PostgreSQL/9.5/bin/pg_dump --file
> "/Users/dpage/.pgadmin/storage/dpage/foo.sql" --host "127.0.0.1"
> --port "5432" --username "postgres" --no-password --verbose --format=c
> --blobs --section=pre-data --section=data --section=post-data
> "!#$%^&*()_+{}|:\"<>?=-\\][';/.,"
>
> Start time: Thu Jun 23 2016 11:49:06 GMT+0100 (BST)
>
> pg_dump: [archiver (db)] connection to database "" failed: invalid
> connection option "!#$%^&*()_+{}|:"<>?"
> error: [Errno 9] Bad file descriptor
> r = self.sock.recv(1024)
> File "/Applications/PyCharm
> CE.app/Contents/helpers/pydev/pydevd_comm.py", line 329, in OnRun
> Traceback (most recent call last):
>
>
>
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-22 Thread Harshal Dhumal
Hi,

PFA updated patch for issues 1220 and 1221

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Jun 21, 2016 at 4:41 PM, Dave Page <dp...@pgadmin.org> wrote:

> Hi
>
> On Tue, Jun 21, 2016 at 11:38 AM, Harshal Dhumal
> <harshal.dhu...@enterprisedb.com> wrote:
> > Hi,
> >
> > PFA patch for issues RM1220 and RM1221
> >
> > Issue fixed: Backup, Restore and Maintenance were causing error with
> > database name  with special characters.
>
> This patch causes the following error when attempting to run a backup:
>
> "quotechar" must be string, not unicode
>
> If I fix that (by wrapping the '' in str()), it then fails with:
>
> need to escape but no escapechar set.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index 5776687..241c43e 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -154,12 +154,7 @@ class BatchProcess(object):
 self.ecode = None
 
 # Arguments
-args_csv_io = StringIO()
-csv_writer = csv.writer(
-args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
-)
-csv_writer.writerow(_args)
-self.args = args_csv_io.getvalue().strip(str('\r\n'))
+self.args = ",".join(str(arg) for arg in _args)
 
 j = Process(
 pid=int(id), command=_cmd, arguments=self.args, logdir=log_dir,

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-21 Thread Harshal Dhumal
Hi,

This patch consist fix for only RM1220
I'll send another patch for RM1221

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Tue, Jun 21, 2016 at 4:08 PM, Harshal Dhumal <
harshal.dhu...@enterprisedb.com> wrote:

> Hi,
>
> PFA patch for issues RM1220 and RM1221
>
> Issue fixed: Backup, Restore and Maintenance were causing error with
> database name  with special characters.
>
> --
> *Harshal Dhumal*
> *Software Engineer*
>
> EnterpriseDB India: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


[pgadmin-hackers] Fix for issue RM1220 and RM 1221 [pgadmin4]

2016-06-21 Thread Harshal Dhumal
Hi,

PFA patch for issues RM1220 and RM1221

Issue fixed: Backup, Restore and Maintenance were causing error with
database name  with special characters.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/misc/bgprocess/processes.py b/web/pgadmin/misc/bgprocess/processes.py
index deb938f..d30db82 100644
--- a/web/pgadmin/misc/bgprocess/processes.py
+++ b/web/pgadmin/misc/bgprocess/processes.py
@@ -156,7 +156,7 @@ class BatchProcess(object):
 # Arguments
 args_csv_io = StringIO()
 csv_writer = csv.writer(
-args_csv_io, delimiter=str(','), quoting=csv.QUOTE_MINIMAL
+args_csv_io, delimiter=str(','), quoting=csv.QUOTE_NONE, quotechar=''
 )
 csv_writer.writerow(_args)
 self.args = args_csv_io.getvalue().strip(str('\r\n'))

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


[pgadmin-hackers] Fix for RM1386 [pgamin4]

2016-06-21 Thread Harshal Dhumal
Hi,

PFA patch for issue RM1386


Issue Fixed: Now User cannot be created with single (or less than 6 )
character password.

-- 
*Harshal Dhumal*
*Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
index 3fad4f1..ca34b2d 100644
--- a/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
+++ b/web/pgadmin/tools/user_management/templates/user_management/js/user_management.js
@@ -210,7 +210,7 @@ define([
 
   this.errorModel.set('newPassword', errmsg);
   return errmsg;
-} else if ('newPassword' in changedAttrs && !_.isUndefined(this.get('newPassword')) &&
+} else if (!_.isUndefined(this.get('newPassword')) &&
   !_.isNull(this.get('newPassword')) &&
   this.get('newPassword').length < 6) {
 

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] Fix for issue RM1336 [pgadmin4]

2016-06-20 Thread Harshal Dhumal
Hi Dave,

I tried to find unique shortcuts keys combination using function keys on
different platforms (windows, mac, linux ) but no success. Any combination
of function keys with either of (or some of them together) Alt, Ctrl, Shift
conflict with either browser functionality or with window functionality
(like resize, move, minimize, maximize etc).

And regarding Ctrl+F5, it is for hard refresh on some browsers.

-- 
*Harshal Dhumal*
*Software Engineer*

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

On Thu, Jun 16, 2016 at 8:03 PM, Dave Page <dp...@pgadmin.org> wrote:

> On Thu, Jun 16, 2016 at 3:28 PM, Ashesh Vashi
> <ashesh.va...@enterprisedb.com> wrote:
> > On Thu, Jun 16, 2016 at 5:10 PM, Dave Page <dp...@pgadmin.org> wrote:
> >>
> >> On Thu, Jun 16, 2016 at 12:14 PM, Harshal Dhumal
> >> <harshal.dhu...@enterprisedb.com> wrote:
> >> > Hi,
> >> >
> >> > As per my offline discussion with Ashesh; He is suggesting not to use
> >> > Function keys as shortcuts.
> >>
> >> Why? That is primarily what they are on the keyboard for.
> >
> > F5 is always bind to refresh function of the browser on linux & windows.
> > Similarly - many shortcuts of browser are bound to the function keys.
> >
> > Hence - I asked not to use F5.
>
> I suggested Ctrl+F5.
>



>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


  1   2   3   >