Index
2013-04-30 10:03 – Max Voß : [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 10:05 – Max Voß : [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 10:11 – Ed Leafe : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 10:51 – Max Voß : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 13:50 – Max Voß : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 14:22 – Ed Leafe : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-04-30 23:10 – Paul McNett : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-05-01 18:39 – Paul McNett : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-05-01 19:32 – Ed Leafe : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
2013-05-01 20:49 – Paul McNett : Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3
Back to top
[dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Max Voß

Posted: 2013-04-30 10:03:51   Link

Hello,

I am trying to update dabo from version 0.9.3 to a newer one, currently

0.9.9 but 0.9.5 doesn't work neither.

The code that worked fine in version 0.9.3 and now creates the error is

the following:

tmpCursor = self.Form.PrimaryBizobj.getTempCursor()

tmpCursor.execute("SELECT rechnung_position.name, preis, anzahl FROM

rechnung INNER JOIN rechnung_position ON rechnung.id=rechnung_id WHERE

re chnung.id=%i ORDER BY position" %

(self.Form.getBizobj("rechnung").getPK()))

ds_artikel = tmpCursor.getDataSet()

Here the complete error:

Traceback (most recent call last):

File

"/home/max/projekte/kolibrill/dabo/dabo/ui/uiwx/dControlMixin.py", line

27, in _onWxHit

self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)

File "/home/max/projekte/kolibrill/dabo/dabo/ui/uiwx/dPemMixin.py",

line 1074, in raiseEvent

super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,

**kwargs)

File "/home/max/projekte/kolibrill/dabo/dabo/lib/eventMixin.py", line

81, in raiseEvent

bindingFunction(event)

File "/tmp/tmpseTPdZ.py", line 4987, in onHit

ds_artikel = tmpCursor.getDataSet()

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

1397, in getDataSet

_correctFieldTypesIfNeeded(rec)

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

219, in _correctFieldTypesIfNeeded

rec[fld_name] = _correctFieldType(rec[fld_name], fld_name)

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

278, in _correctFieldType

return dec.quantize(Decimal("0.%s" % (scale * "0",)))

File "/usr/lib/python2.6/decimal.py", line 2358, in quantize

'quantize result has too many digits for current context')

File "/usr/lib/python2.6/decimal.py", line 3778, in _raise_error

raise error(explanation)

decimal.InvalidOperation: quantize result has too many digits for

current context

It somehow seems that the conversion of the database float-field "preis"

or the integer-field "anzahl" fails, but why? I use a mysql-backend if

that is important to know.

Has anybody an idea what can cause my problem?

Thanks in advance

Max

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1367334231.5128.22.camel@max

©2013 Max Voß
Back to top
[dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Max Voß

Posted: 2013-04-30 10:05:21   Link

Hello,

I am trying to update dabo from version 0.9.3 to a newer one, currently

0.9.9 but 0.9.5 doesn't work neither.

The code that worked fine in version 0.9.3 and now creates the error is

the following:

tmpCursor = self.Form.PrimaryBizobj.getTempCursor()

tmpCursor.execute("SELECT rechnung_position.name, preis, anzahl FROM

rechnung INNER JOIN rechnung_position ON rechnung.id=rechnung_id WHERE

re chnung.id=%i ORDER BY position" %

(self.Form.getBizobj("rechnung").getPK()))

ds_artikel = tmpCursor.getDataSet()

Here the complete error:

Traceback (most recent call last):

File

"/home/max/projekte/kolibrill/dabo/dabo/ui/uiwx/dControlMixin.py", line

27, in _onWxHit

self.raiseEvent(dEvents.Hit, evt, *args, **kwargs)

File "/home/max/projekte/kolibrill/dabo/dabo/ui/uiwx/dPemMixin.py",

line 1074, in raiseEvent

super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,

**kwargs)

File "/home/max/projekte/kolibrill/dabo/dabo/lib/eventMixin.py", line

81, in raiseEvent

bindingFunction(event)

File "/tmp/tmpseTPdZ.py", line 4987, in onHit

ds_artikel = tmpCursor.getDataSet()

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

1397, in getDataSet

_correctFieldTypesIfNeeded(rec)

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

219, in _correctFieldTypesIfNeeded

rec[fld_name] = _correctFieldType(rec[fld_name], fld_name)

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

278, in _correctFieldType

return dec.quantize(Decimal("0.%s" % (scale * "0",)))

File "/usr/lib/python2.6/decimal.py", line 2358, in quantize

'quantize result has too many digits for current context')

File "/usr/lib/python2.6/decimal.py", line 3778, in _raise_error

raise error(explanation)

decimal.InvalidOperation: quantize result has too many digits for

current context

It somehow seems that the conversion of the database float-field "preis"

or the integer-field "anzahl" fails, but why? I use a mysql-backend if

that is important to know.

Has anybody an idea what can cause my problem?

Thanks in advance

Max

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1367334321.5128.23.camel@max

©2013 Max Voß
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Ed Leafe

Posted: 2013-04-30 10:11:12   Link

On Apr 30, 2013, at 10:05 AM, Max Voß <max.voss@optik-stahr.de> wrote:

> tmpCursor.execute("SELECT rechnung_position.name, preis, anzahl FROM

> rechnung INNER JOIN rechnung_position ON rechnung.id=rechnung_id WHERE

> re chnung.id=%i ORDER BY position" %

> (self.Form.getBizobj("rechnung").getPK()))

Generally, doing the direct substitution of the parameters in the SQL statement is a bad idea, as it opens the code up to all sorts of SQL injection attacks. I would try just using '%s' as the placeholder for the parameters, and include a tuple of the parameters you need. This would look like:

pk = self.Form.getBizobj("rechnung").getPK()

sql = """SELECT rechnung_position.name, preis, anzahl

FROM rechnung

INNER JOIN rechnung_position ON rechnung.id=rechnung_id

WHERE rechnung.id=%s

ORDER BY position"""

tmpCursor.execute(sql, (pk, ))

See if that works better for you.

-- Ed Leafe

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/6BAD55D4-D7FF-4F23-9314-E79FAD864FAE@leafe.com

©2013 Ed Leafe
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Max Voß

Posted: 2013-04-30 10:51:02   Link

>

> pk = self.Form.getBizobj("rechnung").getPK()

> sql = """SELECT rechnung_position.name, preis, anzahl

> FROM rechnung

> INNER JOIN rechnung_position ON rechnung.id=rechnung_id

> WHERE rechnung.id=%s

> ORDER BY position"""

> tmpCursor.execute(sql, (pk, ))

>

> See if that works better for you.

>

First thank you for your super fast answer, unfortunately that didn't change anything!

Still the same error when I call:

ds_artikel = tmpCursor.getDataSet()

Could there be a problem with my table-layout or its interpretation of dabo?

Here the SQL-Snippet of the table:

CREATE TABLE IF NOT EXISTS `rechnung_position` (

`id` int(11) NOT NULL AUTO_INCREMENT,

`rechnung_id` int(11) NOT NULL,

`name` varchar(300) NOT NULL,

`preis` float NOT NULL,

`anzahl` int(11) NOT NULL,

`position` int(11) NOT NULL,

PRIMARY KEY (`id`),

KEY `rchnung_id` (`rechnung_id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1665 ;

--

-- Daten für Tabelle `rechnung_position`

--

INSERT INTO `rechnung_position` (`id`, `rechnung_id`, `name`, `preis`, `anzahl`, `position`) VALUES

(9, 1, 'Fassung', 130, 1, 0),

(2, 0, 'test2', 0, 2, 0),

(10, 2, 'Spray', 3, 1, 0),

(8, 1, 'Gläser', 79, 2, 0),

...

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1367337062.5128.36.camel@max

©2013 Max Voß
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Max Voß

Posted: 2013-04-30 13:50:02   Link

Am Dienstag, den 30.04.2013, 17:51 +0200 schrieb Max Voß:

> Could there be a problem with my table-layout or its interpretation of dabo?

>

> Here the SQL-Snippet of the table:

>

>

> CREATE TABLE IF NOT EXISTS `rechnung_position` (

> `id` int(11) NOT NULL AUTO_INCREMENT,

> `rechnung_id` int(11) NOT NULL,

> `name` varchar(300) NOT NULL,

> `preis` float NOT NULL,

> `anzahl` int(11) NOT NULL,

> `position` int(11) NOT NULL,

> PRIMARY KEY (`id`),

> KEY `rchnung_id` (`rechnung_id`)

> ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1665 ;

>

> --

> -- Daten für Tabelle `rechnung_position`

> --

>

> INSERT INTO `rechnung_position` (`id`, `rechnung_id`, `name`, `preis`, `anzahl`, `position`) VALUES

> (9, 1, 'Fassung', 130, 1, 0),

> (2, 0, 'test2', 0, 2, 0),

> (10, 2, 'Spray', 3, 1, 0),

> (8, 1, 'Gläser', 79, 2, 0),

> ...

That is strange, it is in fact a problem with the conversion of my

float-fields when I change the db-fields from float to decimal-type,

what is the better choice anyway, everything works like a charm. But I

probably should open a ticket for that behaviour, since that isn't what

it is supposed to do with float-fields, right?

Max

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/1367347802.2849.6.camel@max

©2013 Max Voß
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Ed Leafe

Posted: 2013-04-30 14:22:15   Link

On Apr 30, 2013, at 1:50 PM, Max Voß <max.voss@optik-stahr.de> wrote:

> That is strange, it is in fact a problem with the conversion of my

> float-fields when I change the db-fields from float to decimal-type,

> what is the better choice anyway, everything works like a charm. But I

> probably should open a ticket for that behaviour, since that isn't what

> it is supposed to do with float-fields, right?

There is a setting: convertFloatToDecimal. This defaults to True, so yes, it is expected behavior.

Paul wrote much of that code and probably has more experience with the float-to-decimal conversion, so I'm hoping he might chime in here.

-- Ed Leafe

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/BE273E34-4F79-4941-8D25-48B7FBA69B20@leafe.com

©2013 Ed Leafe
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Paul McNett

Posted: 2013-04-30 23:10:20   Link

On 4/30/13 12:22 PM, Ed Leafe wrote:

> On Apr 30, 2013, at 1:50 PM, Max Voß <max.voss@optik-stahr.de> wrote:

>

>> That is strange, it is in fact a problem with the conversion of my

>> float-fields when I change the db-fields from float to decimal-type,

>> what is the better choice anyway, everything works like a charm. But I

>> probably should open a ticket for that behaviour, since that isn't what

>> it is supposed to do with float-fields, right?

>

> There is a setting: convertFloatToDecimal. This defaults to True, so yes, it is expected behavior.

>

> Paul wrote much of that code and probably has more experience with the float-to-decimal conversion, so I'm hoping he might chime in here.

I will try to find time to look into this tomorrow (Wed.). I've been planning on

releasing 0.9.10 but I also have a list a mile high for clients. We'll see...

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/518095AC.6040302@ulmcnett.com

©2013 Paul McNett
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Paul McNett

Posted: 2013-05-01 18:39:11   Link

On 4/30/13 12:22 PM, Ed Leafe wrote:

> On Apr 30, 2013, at 1:50 PM, Max Voß <max.voss@optik-stahr.de> wrote:

>

>> That is strange, it is in fact a problem with the conversion of my

>> float-fields when I change the db-fields from float to decimal-type,

>> what is the better choice anyway, everything works like a charm. But I

>> probably should open a ticket for that behaviour, since that isn't what

>> it is supposed to do with float-fields, right?

>

> There is a setting: convertFloatToDecimal. This defaults to True, so yes, it is expected behavior.

>

> Paul wrote much of that code and probably has more experience with the float-to-decimal conversion, so I'm hoping he might chime in here.

I just wrote some test cases to show that indeed, Dabo does convert float to decimal.

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/5181A79F.3000304@ulmcnett.com

©2013 Paul McNett
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Ed Leafe

Posted: 2013-05-01 19:32:59   Link

On May 1, 2013, at 6:39 PM, Paul McNett <p@ulmcnett.com> wrote:

> I just wrote some test cases to show that indeed, Dabo does convert float to decimal.

Of course; that's not the question. The question is why it throws an exception in Max's situation:

[snip]

File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

278, in _correctFieldType

return dec.quantize(Decimal("0.%s" % (scale * "0",)))

File "/usr/lib/python2.6/decimal.py", line 2358, in quantize

'quantize result has too many digits for current context')

File "/usr/lib/python2.6/decimal.py", line 3778, in _raise_error

raise error(explanation)

decimal.InvalidOperation: quantize result has too many digits for

current context

-- Ed Leafe

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/39064840-83AF-487E-9C6E-24A49C2504E2@leafe.com

©2013 Ed Leafe
Back to top
Re: [dabo-users] Problem with custom sql-statement and getDataSet() with version>0.9.3

Author: Paul McNett

Posted: 2013-05-01 20:49:48   Link

On 5/1/13 5:32 PM, Ed Leafe wrote:

> On May 1, 2013, at 6:39 PM, Paul McNett <p@ulmcnett.com> wrote:

>

>> > I just wrote some test cases to show that indeed, Dabo does convert float to decimal.

> Of course; that's not the question. The question is why it throws an exception in Max's situation:

>

> [snip]

> File "/home/max/projekte/kolibrill/dabo/dabo/db/dCursorMixin.py", line

> 278, in _correctFieldType

> return dec.quantize(Decimal("0.%s" % (scale * "0",)))

> File "/usr/lib/python2.6/decimal.py", line 2358, in quantize

> 'quantize result has too many digits for current context')

> File "/usr/lib/python2.6/decimal.py", line 3778, in _raise_error

> raise error(explanation)

> decimal.InvalidOperation: quantize result has too many digits for

> current context

Sorry, I got interrupted while I was typing my message and hit send before I'd said

that this was a preliminary step to digging into the quantize problem. I wanted to

prove to myself that it was still working as it should first.

I'm probably going to have to ask Max to provide me some debug output but I'll review

the thread first in case it's already been presented.

Paul

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/5181C63C.1040705@ulmcnett.com

©2013 Paul McNett