Following error occurs when trying to install the Services module.

PDOException: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Column, parameter, or variable #8: Cannot specify a column width on data type int.

The problem sits in one of the field definitions in the hook_schema():

     'debug' => array(
       'description' => 'Set the endpoint in debug mode.',
         'type'        => 'int',
         'length'      => 2,
         'not null'    => TRUE,
         'default'     => 0
      ),

The patch provided performs an extra check so if length exists and the type is int, it is ignored.

Since this is my first patch, I hope I am doing things right. :-)

Comments

sneyerst’s picture

Status: Active » Needs review

Since a patch is available, I'll put this in 'needs review' state.

damien tournoud’s picture

Status: Needs review » Closed (won't fix)

That's a bug in the Services module, and will likely fail the same on other database engine.

rymo’s picture

Assigned: Unassigned » rymo
Status: Closed (won't fix) » Needs review
StatusFileSize
new783 bytes

See #346450: Schema API: 'length' should be ignored on non varchar and char fields from 2009 and note the accepted solution was that each database driver is responsible for deciding how and when to ignore the length field as necessary. From the Schema API:

'length': The maximal length of a type 'char', 'varchar' or 'text' field. Ignored for other field types.

. Adding a patch to make this check similar to core engines.

rymo’s picture

StatusFileSize
new737 bytes

wrong patch file, here it is

twistor’s picture

Status: Needs review » Needs work

Looks like this patch also touches precision and scale values. That would be a separate issue.

rymo’s picture

Title: Ignore the length of integer fields » Ignore field type attributes that aren't applicable
Status: Needs work » Needs review

unless you're aware of a specific case where 'precision' and 'scale' were successfully applied to SQL field types other than numeric or decimal, this should be a safe patch. the issues are similar and related, and so is the fix.

DrMiaow’s picture

I was just about to post the same issue. Good to see this is being attended to.

I found this issue with a few other modules as well.

DrMiaow’s picture

I have also seen this issue with length applied to 'text'

mgifford’s picture

Would be great to get this into a future release. I can't test it unfortunately.

damien tournoud’s picture

Status: Needs review » Fixed

I'm not sure I like the hand holding here, but I merged this in 7.x-1.x anyway.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.