Conversation
|
Regarding CI failures:
|
|
thank you. although I have to say the original intention of not accepting strs is to prevent mistyping, and to encourage you to use |
I understand your sentiment, and I try to use
That's already the case in methods with If that's a hard requirement for merging, I could remove the impls for
If that's a hard requirement for merging, I could do that. That would still solve my personal issue in my codebase. However, I don't see the point in keeping *That is, if you mean a non- |
|
On a side note, I'd like to come to an understanding and document this area:
|
yes, but I don't think it should be replaced. one could have a struct that impl Display differently from Iden. In some of my old code bases, I'd impl Iden manually on a struct
good to know
how about pub-ing the internal field, i.e. my thinking: we remove String and &String for now, then feature flag not needed |
Ok, removed these. My most important use case is static string literals, so that's ok for me. The PR should now be mergeable for you too.
I've decided not to do this for now, because this doesn't seem very beneficial. This constructor accepts a concrete Updated changelog
|
Thanks for the info, I added docs about this decision to the code. |
tyt2y3
left a comment
There was a problem hiding this comment.
thank you. we'll fix CI later and then make a release
🎉 Released In 0.32.5 🎉Thank you everyone for the contribution! |
|
I've removed some |
|
Cool. I too had a note to myself to do that after this change is released |
Implement
Days before, I made: #[derive(Debug, Clone)]
pub struct IdenStr<'a>(pub &'a str);
impl Iden for IdenStr<'_> {
fn unquoted(&self, s: &mut dyn Write) {
write!(s, "{}", self.0).unwrap();
}
}
#[derive(Debug, Clone)]
pub struct IdenString(pub String);
impl Iden for IdenString {
fn unquoted(&self, s: &mut dyn Write) {
write!(s, "{}", self.0).unwrap();
}
}Now I can try to gradually remove |
|
@tisonkun I agree with you and |
PR Info
New Features
Bug Fixes
Breaking Changes
Changes
(EDIT: outdated, see the up-to-date changelog in the comments below)
Idenfor&str,&StringandString. Now you don't need to wrap strings intoAlias::newwhereT: IntoIdenis needed.This was so noisy! Really drove me insane to hand-write every time. Just look at the diff that I was able to achieve.
Most of the diff is an automaned find-and-replace in VSCode (
Alias::new\(([^)]+)\)->$1, ignoring the changelog). Other than that, there are only two files with interesting changes:In
src/types.rs, I implementedIdenfor&str,&StringandString. That's the actual change that causes strings to implicitly implementIntoIdenand be accepted in methods that needT: IntoIden.This caused a type inference regression, because now these types have multiple
to_stringmethods from multiple traits. I replaced the now-ambiguousto_stringcall insrc/prepare.rs.Compatibility
The type inference issue is technically a breaking change, but it's commonly excluded from semver guarantees and doesn't require a major version bump. To quote
cargo-semver-checks:My mid-sized project (and the latest SeaORM 1.1.10 that it uses) compile fine with these changes.
There shouldn't be any other breaking changes.
cargo semver-checks --release-type patch --baseline-rev master --all-featuresdoesn't report anything.Discussion: future breaking changes
Actually, I'd prefer a general blanket
impl Iden for T where T: AsRef<str>. I think, it makes a lot of sense. MostIdenimpls that I see insea_queryjustmatch Self -> &'static strand thenwrite!it.impl AsRef<str>could handle getting the right&str, and then the blanketimpl Iden for T where T: AsRef<str>takes care of the commons.write_str(self.as_ref()).unwrap(). But this requires a new major version, so I just left aTODOin the code until then.I'm kinda suspicious of
Iden::unquotedthat looks likeDisplay::fmt, andIden::to_stringthat obviously duplicatesToString::to_string(which is exactly what we would get by requiringIden: Display!). But I'm not sure whether theunquotedstring is semantically the same asDisplayand whether it could be replaced by it. Consider documenting this!Also, I don't see the point of having an
Aliasnewtype, instead of using strings directly. This area has very few docs and doesn't explain whyAliasis necessary. So far, I'd like to just deleteAliasin the next major version.And it would be nice to hear something about SeaQL/sea-orm#2327. These
Into*traits are very annoying and don't document why they're necessary.