# Tests failing on table with primary key as string

**URL:** <https://www.ruby-forum.com/t/tests-failing-on-table-with-primary-key-as-string/78718>\
**Category:** Rails\
**Created:** [December 8, 2006, 12:25am UTC](https://www.ruby-forum.com/t/tests-failing-on-table-with-primary-key-as-string/78718 "2006-12-08T00:25:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nappin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f475e1/32.png) [@nappin](https://www.ruby-forum.com/u/nappin)\
**Post date:** [December 8, 2006, 12:25am UTC](https://www.ruby-forum.com/t/tests-failing-on-table-with-primary-key-as-string/78718/1 "2006-12-08T00:25:30Z")

</div>

Hi,  
I’ve got a table where the primary key named :id is a string.  
Everything works great using the app however when I try to write a test  
I notice that rails keeps converting this id into a Fixnum, which  
results in it querying the database for ids that don’t exist. Is there  
anyway I can get my tests to work?

For example, I have a fixture with  
ABook:  
id: “123456789X”  
title: “Title of my book”

then in my test if I print out books(:ABook).id.class I get a FixNum.

I’m using edge Rails by the way.

Thanks,  
Ray
