Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In email functionality : Second name is not appending in email most of the time #1000

Closed
Pandicool opened this issue May 25, 2022 · 9 comments · Fixed by #2506
Closed

In email functionality : Second name is not appending in email most of the time #1000

Pandicool opened this issue May 25, 2022 · 9 comments · Fixed by #2506
Labels
good first issue Good for newcomers help wanted Extra attention is needed m: internet Something is referring to the internet module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Milestone

Comments

@Pandicool
Copy link

Pandicool commented May 25, 2022

Describe the bug

Trying to create 100 emails with first name, second name, and provider. but generating email doesn't have a second name most of the time.

Reproduction

Code:

const firstName = "groot";
const secondName = "at";
const random = Math.floor(Math.random() *100000);
secondName = secondName+random;
console.log("First name: ",firstName,"Second name : ",secondName)
const email = faker.internet.email(firstName,secondName,provider).replace(/[^a-zA-Z0-9@.]/g, "");
console.log(email);

Response:

[0-0] First name: groot Second name: at29913
[0-0] groot56@gmail.com
[0-0] First name: groot Second name: at30314
[0-0] groot.at30314@gmail.com
[0-0] First name: groot Second name: at13277
[0-0] groot.at1327778@gmail.com
[0-0] First name: groot Second name: at60615
[0-0] grootat6061518@gmail.com
[0-0] First name: groot Second name: at84925
[0-0] groot5@gmail.com
[0-0] First name: groot Second name: at67487
[0-0] grootat6748741@gmail.com
[0-0] First name: groot Second name: at1124
[0-0] groot.at112430@gmail.com
[0-0] First name: groot Second name: at15594
[0-0] groot94@gmail.com
[0-0] First name: groot Second name: at77943
[0-0] groot.at7794310@gmail.com
[0-0] First name: groot Second name: at66877
[0-0] groot10@gmail.com
[0-0] First name: groot Second name: at73118
[0-0] groot41@gmail.com
[0-0] First name: groot Second name: at43517
[0-0] grootat43517@gmail.com
[0-0] First name: groot Second name: at66282
[0-0] groot62@gmail.com
[0-0] First name: groot Second name: at4783
[0-0] groot.at4783@gmail.com
[0-0] First name: groot Second name: at80369
[0-0] groot.at803690@gmail.com
[0-0] First name: groot Second name: at98724
[0-0] grootat9872427@gmail.com
[0-0] First name: groot Second name: at42108
[0-0] groot62@gmail.com
[0-0] First name: groot Second name: at23822
[0-0] grootat23822@gmail.com
[0-0] First name: groot Second name: at75730
[0-0] grootat757300@gmail.com
[0-0] First name: groot Second name: at17076
[0-0] grootat17076@gmail.com
[0-0] First name: groot Second name: at27913
[0-0] groot25@gmail.com
[0-0] First name: groot Second name: at6139
[0-0] groot.at613994@gmail.com
[0-0] First name: groot Second name: at29583
[0-0] groot92@gmail.com
[0-0] First name: groot Second name: at34788
[0-0] groot7@gmail.com
[0-0] First name: groot Second name: at53021
[0-0] grootat53021@gmail.com
[0-0] First name: groot Second name: at91160
[0-0] groot.at9116062@gmail.com
[0-0] First name: groot Second name: at74768
[0-0] groot85@gmail.com
[0-0] First name: groot Second name: at41251
[0-0] grootat41251@gmail.com

Additional Info

in above response most of the time second name is not appending please check on that issue

@Pandicool Pandicool added the s: pending triage Pending Triage label May 25, 2022
@Pandicool
Copy link
Author

Shinigami92 could you please confirm this issue is persist

@ST-DDT
Copy link
Member

ST-DDT commented May 25, 2022

let localPart: string = this.faker.helpers.slugify(
this.userName(firstName, lastName)
);

userName(firstName?: string, lastName?: string): string {
let result: string;
firstName = firstName || this.faker.name.firstName();
lastName = lastName || this.faker.name.lastName();
switch (this.faker.datatype.number(2)) {
case 0:
result = `${firstName}${this.faker.datatype.number(99)}`;
break;
case 1:
result =
firstName + this.faker.helpers.arrayElement(['.', '_']) + lastName;
break;
case 2:
result = `${firstName}${this.faker.helpers.arrayElement([
'.',
'_',
])}${lastName}${this.faker.datatype.number(99)}`;
break;
}
result = result.toString().replace(/'/g, '');
result = result.replace(/ /g, '');
return result;
}

From the code, it looks like this is expected behavior.

@ejcheng ejcheng added s: needs decision Needs team/maintainer decision and removed s: pending triage Pending Triage labels May 25, 2022
@kris71990
Copy link
Contributor

This issue appears to have been alluded to in #1044 with reference to unpredictable data in tests.

The behavior is expected, but should it really be desired? It seems to me that if a user provides a last name to userName() and email(), the last name should be included in the username and email. Interested in the reasoning behind the current solution.

Apologies if this is already being addressed!

@ST-DDT
Copy link
Member

ST-DDT commented Jun 24, 2022

The behavior is expected, but should it really be desired?

IMO If the users wants to have email-adresses that are always firstname.lastname@xyz.abc,
then they could generate them exactly like that.
The email address method adds some variation to the generated email addresses.

Maybe, we could add/change the methods to use an address/name part, that is always used as is.

@kris71990
Copy link
Contributor

IMO If the users wants to have email-adresses that are always firstname.lastname@xyz.abc, then they could generate them exactly like that. The email address method adds some variation to the generated email addresses.

Fair enough; I certainly wouldn't want to sacrifice any variety. Just not sure why the last name couldn't be included every time if provided.

Maybe, we could add/change the methods to use an address/name part, that is always used as is.

I like this idea.

@xDivisionByZerox xDivisionByZerox added the m: internet Something is referring to the internet module label Jul 29, 2022
@ST-DDT
Copy link
Member

ST-DDT commented Jan 19, 2023

Team decision

We should change the email function to take the inputs more into account.

If parameters are passed to the method, then we will specific patterns to use them.
If no parameters are passed to the method, then we randomly generate the username using fake patterns.

@ST-DDT ST-DDT added help wanted Extra attention is needed p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug and removed s: needs decision Needs team/maintainer decision labels Jan 19, 2023
@ST-DDT ST-DDT moved this to Todo in Faker Roadmap Jan 19, 2023
@Shinigami92
Copy link
Member

Hi, sorry I'm late to the party
I needed some time for my sanity, but anyways

This was always something I had back in my mind I wanted to have changed in faker
This is a "left-over" from pre v6 times of faker

I would like to change the behavior of this method alongside with

Then we can re-code it to userName({ firstName, lastName }: { firstName?: string, lastName?: string } = {}): string
This has the benefit that you can pass lastName without firstName and vice versa or just both (or non of both)
Then the userName method takes everything into account that was passed into it, always, everything
$$$ profit

@kris71990
Copy link
Contributor

Nice to see this issue bumped, and agree with all the reasoning here.

I would tackle this myself but unfortunately I don't think I can dedicate any time to it very soon.

@R-Strouse
Copy link

I came here to log this issue as well, hope it gets fixed soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed m: internet Something is referring to the internet module p: 1-normal Nothing urgent s: accepted Accepted feature / Confirmed bug
Projects
No open projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

8 participants