Skip to content

Fix cross-driver boolean handling for IS_MANDATORY field in consentpurpose store #27

@coderabbitai

Description

@coderabbitai

Summary

The IS_MANDATORY field mapping in consent-server/internal/consentpurpose/store.go (GetPurposeElements) only handles the int64 type for the is_mandatory column:

if isMandatory, ok := row["is_mandatory"].(int64); ok {
    p.IsMandatory = isMandatory != 0
}

When using the PostgreSQL driver (added in #26), if IS_MANDATORY is defined as BOOLEAN, the driver may return a native bool instead of int64. The current type assertion will fail silently, leaving p.IsMandatory as false for all rows.

The file already defines getString() and getStringPtr() cross-driver helpers for string normalization — the same pattern should be applied for boolean fields.

Suggested Fix

switch v := row["is_mandatory"].(type) {
case bool:
    p.IsMandatory = v
case int64:
    p.IsMandatory = v != 0
}

Alternatively, introduce a getBool(row map[string]interface{}, key string) bool helper (similar to getString) to normalize boolean values across MySQL, PostgreSQL, and SQLite drivers.

References

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