From 9451f84c5a20550c109141e64c61b6f3710550e5 Mon Sep 17 00:00:00 2001 From: Kevin Danielsen <53810762+dekode-kevin@users.noreply.github.com> Date: Thu, 3 Aug 2023 15:19:44 +0200 Subject: [PATCH] Feature/purge type (#22) --- README.md | 43 +++++++++++++++++++------------------ internal/helpers/helpers.go | 5 +++++ 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f696c9e..bd58ae9 100644 --- a/README.md +++ b/README.md @@ -128,28 +128,29 @@ Supposing you have a WordPress database and you need to modify certain meta, be Each column stores a certain type of data, be it a name, username, email, etc. The `type` property in the config is used to define the type of data stored, and ultimately the type of random data to be inserted into the field. [https://github.com/dmgk/faker](https://github.com/dmgk/faker) is used for generating the fake data. These are the types currently supported: -| Type | Example output | -| --- | --- | -| `username` | `micah_pfeffer` | -| `password` | `5ccf672d5c73748146be6b37568efa57` | -| `email` | `maritza@farrell.org` | -| `url` | `http://sporerhamill.net/kyla.schmitt` | -| `name` | `Natasha Hartmann` | -| `firstName` | `Carolina` | -| `lastName` | `Kohler` | -| `phoneNumber` | `+49-131-0003060` | -| `addressFull` | `6071 Heaney Island Suite 553, Ebbaville Texas 37307` | -| `addressStreet` | `"586 Sylvester Turnpike"` | -| `addressPostCode` | `31340` | -| `addressCountry` | `Uruguay` | +| Type | Example output | +|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `username` | `micah_pfeffer` | +| `password` | `5ccf672d5c73748146be6b37568efa57` | +| `email` | `maritza@farrell.org` | +| `url` | `http://sporerhamill.net/kyla.schmitt` | +| `name` | `Natasha Hartmann` | +| `firstName` | `Carolina` | +| `lastName` | `Kohler` | +| `phoneNumber` | `+49-131-0003060` | +| `addressFull` | `6071 Heaney Island Suite 553, Ebbaville Texas 37307` | +| `addressStreet` | `"586 Sylvester Turnpike"` | +| `addressPostCode` | `31340` | +| `addressCountry` | `Uruguay` | | `paragraph` | `Lorem ipsum dolor sit amet, fabulas nostrum recteque vel ea, sit ut nemore similique. Ad per dicam molestie, nostro constituto duo ad. Ex scripta impedit cum, vidisse feugiat vivendum cum ad, cu liber senserit mediocrem pro.` | -| `shortString` | `wqFyJIrXYfVP7cLwqFyJIrXYfVP7cL` | -| `ipv4` | `121.204.82.227` | -| `companyName` | `Aufderhar LLC` | -| `companyNumber` | `123456789` | -| `creditCardNumber` | `1234-2121-1221-1211` | -| `creditCardExpiryDate` | `2015-11-11` | -| `creditCardType` | `mastercard` | +| `shortString` | `wqFyJIrXYfVP7cLwqFyJIrXYfVP7cL` | +| `ipv4` | `121.204.82.227` | +| `companyName` | `Aufderhar LLC` | +| `companyNumber` | `123456789` | +| `creditCardNumber` | `1234-2121-1221-1211` | +| `creditCardExpiryDate` | `2015-11-11` | +| `creditCardType` | `mastercard` | +| `purge` | | If you need another type, please feel free to add support and file a PR! diff --git a/internal/helpers/helpers.go b/internal/helpers/helpers.go index 14a3d0d..cc47551 100644 --- a/internal/helpers/helpers.go +++ b/internal/helpers/helpers.go @@ -31,6 +31,7 @@ func GetFakerFuncs() map[string]func(*sqlparser.SQLVal) *sqlparser.SQLVal { "creditCardNumber": generateCreditCardNumber, "creditCardExpiryDate": generateCreditCardExpiryDate, "creditCardType": generateCreditCardType, + "purge": generateEmptyString, } return fakerHelpers @@ -116,3 +117,7 @@ func generateCompanyNumber(value *sqlparser.SQLVal) *sqlparser.SQLVal { func generateShortString(value *sqlparser.SQLVal) *sqlparser.SQLVal { return sqlparser.NewStrVal([]byte(faker.Lorem().Characters(30))) } + +func generateEmptyString(value *sqlparser.SQLVal) *sqlparser.SQLVal { + return sqlparser.NewStrVal([]byte("")) +} \ No newline at end of file