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

Add support for a running number #33

Closed
jerekarppinen opened this issue Oct 9, 2024 · 5 comments
Closed

Add support for a running number #33

jerekarppinen opened this issue Oct 9, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@jerekarppinen
Copy link

Example config:

tables = {
   `customer` = {
     `name`   = 'MyCustomer' i
   }
}

outputs:

MyCustomer 1
MyCustomer 2
MyCustomer 3
@ppomes ppomes self-assigned this Oct 9, 2024
@ppomes ppomes added the enhancement New feature or request label Oct 9, 2024
@ppomes
Copy link
Owner

ppomes commented Oct 10, 2024

Hi @jerekarppinen,

Thanks for your request.

I just added this features. Can you pull the main branch, and check the tests tests/appendindex.conf and tests/prependindex.conf?

As you will see, you can new specify (append or prepend) a row index to a fixed value.

This should cover your needs, can you confirm?

Regards,
Pierre

@jerekarppinen
Copy link
Author

Looks great!

Now I just have the first MyCustomer 1 twice:

DROP TABLE IF EXISTS `customer`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `customer` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `other_table_id` int DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=57 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

LOCK TABLES `customer` WRITE;
/*!40000 ALTER TABLE `customer` DISABLE KEYS */;
INSERT INTO `customer` VALUES (1,'MyCustomer 1',5846912),(2,'MyCustomer 1',5700228),(3,'MyCustomer 2',5770759) ....
/*!40000 ALTER TABLE `customer` ENABLE KEYS */;
UNLOCK TABLES;

I checked the original data and those two have different values.

Config used:

tables = {
   `customer` = {
     `name`   = appendindex 'MyCustomer '
   }
}

@ppomes
Copy link
Owner

ppomes commented Oct 14, 2024

Thanks for the test! This should be fix now, can you pull and try again?

Regards,
Pierre

@jerekarppinen
Copy link
Author

It's fixed! Thanks!

@ppomes
Copy link
Owner

ppomes commented Oct 14, 2024

Thanks for your quick feedback. Issue closed!

@ppomes ppomes closed this as completed Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants