Skip to content

EncodedSession.putValue always 'puts' booleans as integers #201

Description

@TheDistributor

In this code:

` def putValue(self, value): # pylint: disable=too-many-return-statements
# type: (Any) -> EncodedSession
"""Call the supporting function based on the type of the value."""
if value is None:
return self.putNull()

    if isinstance(value, int):
        return self.putInt(value)
        
    if isinstance(value, float):
        return self.putDouble(value)

    if isinstance(value, decimal.Decimal):
        return self.putScaledInt(value)
            
    if isinstance(value, datatype.Timestamp):
        # Note: Timestamp must be above Date because it inherits from Date
        return self.putScaledTimestamp(value)
    
    if isinstance(value, datatype.Date):
        return self.putScaledDate(value)
    
    if isinstance(value, datatype.Time):
        return self.putScaledTime(value)
    
    if isinstance(value, datatype.Binary):
        return self.putOpaque(value)

    if isinstance(value, bool):
        return self.putBoolean(value)

    # we don't want to autodetect lists as being VECTOR, so we
    # only bind double if it is the explicit type
    if isinstance(value, datatype.Vector):
        return self.putVector(value)

    # I find it pretty bogus that we pass str(value) here: why not value?
    return self.putString(str(value))

`

Since bool is an 'int', we will never call 'putBoolean'. The bool check needs to be before the int check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions