Skip to content

Conversation

uldisn
Copy link
Contributor

@uldisn uldisn commented Jun 16, 2025

Q A
Is bugfix? ✔️
New feature?
Breaks BC?
Fixed issues [(https://github.com//issues/557)]

@schmunk42 schmunk42 self-requested a review June 16, 2025 09:40
Copy link
Contributor

@schmunk42 schmunk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks BC to my understanding!

What you could do is moving constantName to a callback with the current function as a default.

Copy link
Member

@samdark samdark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a line for CHANGELOG.

const JUNCTION_RELATION_VIA_TABLE = 'table';
const JUNCTION_RELATION_VIA_MODEL = 'model';

const SYMBOLS_ABBREVIATION = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const SYMBOLS_ABBREVIATION = [
const SYMBOLS_ABBREVIATION = [

@schmunk42
Copy link
Contributor

@samdark This needs rework, IMHO it is not BC.

Test have to cover the current behavior eg. "B+" and "B-" leading to the same constant.
What is about "A-Foo", "A-Bar"?

And a test for the new behavior when setting the constantNameCallback in the class.

CC: @rob006

@uldisn
Copy link
Contributor Author

uldisn commented Jun 21, 2025

And a test for the new behavior when setting the constantNameCallback in the class.
I didn't understand.

@uldisn uldisn requested a review from schmunk42 June 21, 2025 07:23
@samdark
Copy link
Member

samdark commented Jun 27, 2025

@schmunk42 is it better now?

@schmunk42
Copy link
Contributor

@schmunk42 is it better now?

No, I don't see my points addresses.
First, there should be tests covering the current functionality.

@uldisn
Copy link
Contributor Author

uldisn commented Jul 11, 2025

@samdark all generated code is covered

@schmunk42
Copy link
Contributor

Still breaks BC.

This line should read:

$constantName = $this->constantNameCallback($column->name, $value)

This is the public property

public $constantNameCallback = function($name, $value){
  return strtoupper(Inflector::slug($name . ' ' . $value, '_'));
}

Somehow like that... I haven't tested it.

With this you should be able to plug-in any constant name generator function you want.

@uldisn
Copy link
Contributor Author

uldisn commented Jul 24, 2025

@schmunk42

@schmunk42
Copy link
Contributor

Honestly, this is a huge change, I can not tell if it is BC or not.
Also I am currently in holidays and have no time to review it.

I am against it, sorry.

@uldisn
Copy link
Contributor Author

uldisn commented Sep 5, 2025

?

@schmunk42
Copy link
Contributor

So, to my understanding here's some magic, which handles stuff like A-Foo the way it was.

https://github.com/yiisoft/yii2-gii/pull/556/files#diff-58ec64246f814497eb0524bc73fc58181b344edc0651e9e1014b004ee012554aR127-R145

But if you have something like A (1):

  • current code: A_1
  • PR code: A_OPENING_PARENTHESIS_1_CLOSING_PARENTHESIS

correct?

As mentioned before, it's too opinionated IMHO and an approach with a simple callback would be the best:
#556 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants