# Inconsistent data in mySQL using string field

**URL:** <https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222>\
**Category:** Rails\
**Created:** [January 20, 2009, 8:27pm UTC](https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222 "2009-01-20T20:27:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rainyglade](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@rainyglade](https://www.ruby-forum.com/u/rainyglade)\
**Post date:** [January 20, 2009, 8:27pm UTC](https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222/1 "2009-01-20T20:27:41Z")

</div>

I have a migration:

class CreateCodeRequests \< ActiveRecord::Migration  
def self.up  
create\_table :code\_requests do |t|  
t.string :key\_number  
t.string :version  
t.datetime :maint\_end\_date  
t.string :nls\_name  
t.string :company\_name  
t.string :email\_address  
t.boolean :temp  
t.integer :temp\_week\_to\_start  
t.integer :temp\_num\_weeks

```
  t.timestamps
end

```

end

def self.down  
drop\_table :code\_requests  
end  
end

and two fixtures in a .yml file:

one:  
id: 1  
key\_number: 0200699  
version: 12.2  
maint\_end\_date: 2009-05-31 12:00:0  
nls\_name: automod  
company\_name: U of Anywyere  
email\_address: removed\_email\_address@domain.invalid  
temp: false  
temp\_week\_to\_start:  
temp\_num\_weeks:

two:  
id: 2  
key\_number: 0200100  
version: 12.2  
maint\_end\_date: 2009-03-27 12:00:00  
nls\_name:  
company\_name: Company1  
email\_address: removed\_email\_address@domain.invalid  
temp: false  
temp\_week\_to\_start:  
temp\_num\_weeks:

When I do the migration and load the fixtures I get data in the  
key\_number field of 0200699 for the first one, but 65600 for the 2nd  
one, unless I put quotes around “0200100”. What could be the reason for  
this?

TIA!

LG Rains

---

<div class="post-metadata">

**Author:** ![rainyglade](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@rainyglade](https://www.ruby-forum.com/u/rainyglade)\
**Post date:** [January 20, 2009, 8:35pm UTC](https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222/2 "2009-01-20T20:35:07Z")

</div>

On 20 Jan 2009, at 19:27, Louise R. wrote:

> When I do the migration and load the fixtures I get data in the  
> key\_number field of 0200699 for the first one, but 65600 for the 2nd  
> one, unless I put quotes around “0200100”. What could be the reason  
> for  
> this?

because yml assumes that it’s a number in base 8. with the quotes it  
sees that it’s a string and doesn’t do anything with it.

Fred

---

<div class="post-metadata">

**Author:** ![rainyglade](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@rainyglade](https://www.ruby-forum.com/u/rainyglade)\
**Post date:** [January 20, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222/3 "2009-01-20T21:56:01Z")

</div>

Frederick C. wrote:

> On 20 Jan 2009, at 19:27, Louise R. wrote:
> 
> > When I do the migration and load the fixtures I get data in the  
> > key\_number field of 0200699 for the first one, but 65600 for the 2nd  
> > one, unless I put quotes around “0200100”. What could be the reason  
> > for  
> > this?
> 
> because yml assumes that it’s a number in base 8. with the quotes it  
> sees that it’s a string and doesn’t do anything with it.
> 
> Fred

Good answer, I knew that 🙂 Except, 0200699 has the leading 0 on it.  
Is it the fact that 0200699 has 9 in it - a non-base 8 digit?

Thanks,  
Louise

---

<div class="post-metadata">

**Author:** ![rainyglade](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@rainyglade](https://www.ruby-forum.com/u/rainyglade)\
**Post date:** [January 20, 2009, 10:05pm UTC](https://www.ruby-forum.com/t/inconsistent-data-in-mysql-using-string-field/158222/4 "2009-01-20T22:05:16Z")

</div>

On 20 Jan 2009, at 20:56, Louise R. wrote:

> > > 
> > 
> > because yml assumes that it’s a number in base 8. with the quotes it  
> > sees that it’s a string and doesn’t do anything with it.
> > 
> > Fred
> 
> Good answer, I knew that 🙂 Except, 0200699 has the leading 0 on it.  
> Is it the fact that 0200699 has 9 in it - a non-base 8 digit?

I’d guess so.

Fred
