Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
bigint datatype in Fixtures
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Shukuboy  
View profile  
 More options Nov 9 2011, 5:46 pm
From: Shukuboy <shuku...@gmail.com>
Date: Wed, 9 Nov 2011 14:46:51 -0800 (PST)
Local: Wed, Nov 9 2011 5:46 pm
Subject: bigint datatype in Fixtures
Hi,

I've been spending a few hours trying to work out why my unit-tests
don't work, while if I run the same code on the website with the same
data works fine.

Well, here's the story:
-  I've got 2 columns of type 'bigint' in one of my database tables,
on which I do comparison based lookups.  Therefore they cannot be
varchars.  They can't be ints, because they're too big and if I were
to turn them to ints, half of my data gets truncated.
-  They work quite fine with my models and a find method like this
fetches the right results:
$data =   $this -> find('first' , array('conditions' => array('number1
<=' => $number , 'number2 >=' => $number))) ;

-  The problem arises when I'm testing using fixtures. Bake will setup
both of the two numbers as type 'integer' in the fields declaration.
Using $import in the fixture will have similar results.

public $fields = array(
                'id' => array('type' => 'integer', 'null' => false, 'default' =>
NULL, 'key' => 'primary', 'collate' => NULL, 'comment' => ''),
                'number1' => array('type' => 'integer', 'null' => false, 'default'
=> NULL, 'collate' => NULL, 'comment' => ''),
                'number2' => array('type' => 'integer', 'null' => false, 'default'
=> NULL, 'collate' => NULL, 'comment' => ''),
                ... truncated ...
        );

Now when I run my tests,  the exact same find query, fetches only
records which fall within the boundary of int(11).

Playing around I ended up changing the Fixture definition to define
the two numbers as strings :

public $fields = array(
                'id' => array('type' => 'integer', 'null' => false, 'default' =>
NULL, 'key' => 'primary', 'collate' => NULL, 'comment' => ''),
                'number1' => array('type' => 'string', 'null' => false, 'default' =>
NULL, 'collate' => NULL, 'comment' => ''),
                'number2' => array('type' => 'string', 'null' => false, 'default' =>
NULL, 'collate' => NULL, 'comment' => ''),
                ... truncated ...
        );

and suddenly everything is honky dory.

My questions are :
1) why do I get an inconsistent behaviours between my application and
my tests ?
2) my current solution to get the tests working is bodge.  What's the
best way to get this working across the app?

Cheers,
Shuku


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
100rk  
View profile  
 More options Nov 9 2011, 7:21 pm
From: 100rk <lubomir.st...@gmail.com>
Date: Wed, 9 Nov 2011 16:21:18 -0800 (PST)
Local: Wed, Nov 9 2011 7:21 pm
Subject: Re: bigint datatype in Fixtures
I had similar problem with 'double' type and CakeSchema (therefore
with CDC plugin "migrations" as well) - DboSource maps it as "float".
Straightforward solution (not DBO-independent, though) was raw sql
"ALTER TABLE ... MODIFY COLUMN ..." statement in after() callback.
Take it just as possible direction, I'm not sure if it is possible to
change descendant of CakeTestFixture to run raw sql after table is
created and before test data are inserted.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »