Skip to content

FixedString(N) conflict with blanket impl of clickhouse::sql::Bind #395

Description

@redfoxdev58

I'm facing an issue that FixedString(N) type for insertion and selection is requiring [u8; n] which is obviously good.
But as clickhouse::sql::Bind has blanket implementation on impl<S: serde::Serialize> it is binding it as Bytes as well ( obviously ),
but itself clickhouse doesn't support that comparison.

So for type:

macro_rules! ascii_byte_type {
	($typ: ident, $size: expr, $comment: expr) => {
		#[doc = $comment]
		#[derive(serde::Serialize, serde::Deserialize, Clone, PartialEq, Eq, Hash)]
		#[serde(transparent)]
		pub struct $typ([u8; $size]);
		impl FromStr for $typ {
			type Err = anyhow::Error;

			fn from_str(s: &str) -> Result<Self, Self::Err> {
				if !s.is_ascii() {
					anyhow::bail!("{} should be {} bytes of ASCII chars", stringify!($typ), $size);
				}

				Ok(match s.len() {
					$size => Self(s.as_bytes().try_into()?),
					v => anyhow::bail!("{} can't be ascid due to length: {v}", stringify!($typ)),
				})
			}
		}
	};
}

ascii_byte_type!(SomeStruct, 24);

I'm getting error:

bad response: Code: 386. DB::Exception: There is no supertype for types FixedString(24), Tuple(UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8) because some of them are Tuple and some of them are not: while executing 'FUNCTION equals(id : 0, (49, 48, 48, 49, 102, 49, 50, 49, 97, 53, 48, 49, 52, 55, 100, 48, 48, 48, 48, 51, 49, 56, 52, 51) : 3) -> equals(id, (49, 48, 48, 49, 102, 49, 50, 49, 97, 53, 48, 49, 52, 55, 100, 48, 48, 48, 48, 51, 49, 56, 52, 51)) UInt8 : 5'. (NO_COMMON_TYPE) (version 23.9.1.1095 (official build))

Is there any way to fix or request a feature for that? Cause negative trait impls are still not there and with unstable anyways there is no way to do negative on positive

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions