lecosson / assql

Automatically exported from code.google.com/p/assql
0 stars 0 forks source link

Not getting data if record first field is blank #99

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a new database table.
2. Enter a new record in the table having first field blank.
3. Fetch the row from database.

What is the expected output? What do you see instead?

A ResultSet should be returned with having the row data. However it is
returning MySqlResponse.

Please provide any additional information below.

According to my case, I have a database table for storing settings details
for the application and it have first field as companyName of type
char(255). If companyName have the value '' and rest of the fields have
proper data then I got MySqlResponse rather then ResultSet object. If I
made changes in database for companyName say 'xyz' then it starts working
fine and I got ResultSet object.

According to my exploration.

When first field have '' data then under QueryHandler class inside
handleNextPacket() method it gets field_count = 0 while reading bytes and
assumes it as response packet rather then data packet and return RESPONSE
to all the responders.

Original issue reported on code.google.com by vinod.ty...@gmail.com on 17 Mar 2010 at 6:44

GoogleCodeExporter commented 9 years ago
Please update for the same ASAP as we are blocked due to this issue. Thanks.

Original comment by vinod.ty...@gmail.com on 17 Mar 2010 at 3:44

GoogleCodeExporter commented 9 years ago
I've come across this issue as well.

If the first field in the result is blank then the result data is of the wrong 
type (MySqlResponse where affectedRows = <length of second field> and insertID 
= <ASCII code of first char of second field> ). This can be confirmed with a 
very simple query:

select '', 'abcdefg';

This gives us:

affectedRows    7   <length of 'abcdefg'>
insertID    97  <'a'>

My workaround where I can expect this to happen is to use a query like this:

select 1 as `dummy`, t.* from testtbl t;

Original comment by sha...@coderscollective.com on 10 Jan 2013 at 1:06

GoogleCodeExporter commented 9 years ago
In case anyone can get near fixing this, the issue lies in QueryHandler.as, 
lines 142/144:

142: var field_count:int = packet.readByte() & 0xFF;
143:        
144: if ( field_count == 0x00 )

In our case the field_count is being read as 0 when the first field is blank.

Original comment by sha...@coderscollective.com on 10 Jan 2013 at 1:19