test_mssql fails under Windows

Issue #1484 resolved
Anonymous created an issue

The test test.dialect.test_mssql.BinaryTest.test_binary fails under Windows. The problem is opening a binary file in text mode. Trivial patch against trunk attached.

Comments (8)

  1. Michael Trier
    • changed assignee to empty
    • changed milestone to 0.5.6

    Well this is fixing a prior workaround. So the actual change is somewhere else, where we are padding the output. Apparently someone changed the behavior of Binary from BINARY to VARBINARY. Which is fine, but the test needs to change. Thanks for the information. I'm working on it now.

  2. Michael Trier

    I'm having trouble tracking the source of the problem. I know how to fix it but don't understand why it doesn't work properly otherwise. The issue with the third test in this suite is that we are passing None for the data insert. For some reason this is setting up the prepared statement as:

    declare @p1 int
    set @p1=-1
    exec sp_prepexec @p1 output,N'@P1 int,@P2 varchar(1),@P3 varchar(1),@P4 varbinary(99),@P5 varchar(19),@P6 
    varchar(1)',N'INSERT INTO binary_table (primary_id, data, data_image, data_slice, misc, pickled) VALUES (@P1, 
    @P2, @P3, @P4, @P5, 
    @P6)',3
    select @p1
    

    Causing the following error:

    ProgrammingError: (ProgrammingError) ('42000', '[42000](42000) [Microsoft](Microsoft)[SQL Server Driver](ODBC)[Server](SQL)Implicit conversion
    from data type varchar to varbinary is not allowed. Use the CONVERT function to run this query. (257)
    

    Removing the data element from the insert we get:

    declare @p1 int
    set @p1=-1
    exec sp_prepexec @p1 output,N'@P1 int,@P2 varchar(1),@P3 varbinary(99),@P4 varchar(19),@P5 varchar(1)',N'INSERT 
    INTO binary_table (primary_id, data_image, data_slice, misc, pickled) VALUES (@P1, @P2, @P3, @P4, 
    @P5)',3
    select @p1
    

    Which is successful in running the tests but the specified parameters are incorrect (VARCHAR(1) instead of IMAGE). The other inserts where the image types are specified (not None) are properly prepared as (notice the correct image types):

    declare @p1 int
    set @p1=-1
    exec sp_prepare @p1 output,N'@P1 int,@P2 image,@P3 image,@P4 varbinary(99),@P5 varchar(19),@P6 
    varbinary(111)',N'INSERT INTO binary_table (primary_id, data, data_image, data_slice, misc, pickled) VALUES (@P1, 
    @P2, @P3, @P4, @P5, @P6)',1
    select @p1
    

    I'm having trouble tracking down what sets up those prepared types. Suggestions?

  3. Log in to comment