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

Creating a Towny town doesnt work 'worldName' cannot be null #64

Open
TKwSni opened this issue Oct 19, 2019 · 5 comments
Open

Creating a Towny town doesnt work 'worldName' cannot be null #64

TKwSni opened this issue Oct 19, 2019 · 5 comments
Assignees
Labels
Type: Bug Something isn't working

Comments

@TKwSni
Copy link

TKwSni commented Oct 19, 2019

Hi,

When creating a town using towny, it gives me this error.

https://pastebin.com/raw/uqYdccvs

Any way to fix it please ? i'm running my server with this plugin and this is very important, as nobody can create any towns atm.

Thank you!

@pavog
Copy link
Owner

pavog commented Oct 21, 2019

Hi @Blackyvk,
thanks for reporting this issue.

I had a look into it and found out that Towny tries to create an account for the town.
Craftconomy3 adds the name of the world to the account but it cannot determine it if the account holder is not a player. This shouldn't be a problem since the column definition for the world name also accepts null values.
Do you have phpmyadmin or any other mysql administration tool to have a look a the table structure of the balance table?
If so it would be helpful if you send me a screenshot of the table structure / definition.

Thanks in advance and best regards.

@pavog pavog self-assigned this Oct 21, 2019
@pavog pavog added the Type: Bug Something isn't working label Oct 21, 2019
@TKwSni
Copy link
Author

TKwSni commented Oct 21, 2019

Thank you for reply, here is my balance table, I think I tried to remove the "NOT NULL" from worldName and for that i had to remove the PRIMARY KEY, but then I got duplicates error when trying to create a town.

CREATE TABLE `aiu_balance` (
  `balance` double DEFAULT NULL,
  `worldName` varchar(255) NOT NULL DEFAULT '',
  `username_id` int(11) NOT NULL DEFAULT '0',
  `currency_id` varchar(50) NOT NULL DEFAULT '',
  PRIMARY KEY (`worldName`,`username_id`,`currency_id`),
  KEY `aiu_fk_balance_account` (`username_id`),
  KEY `aiu_fk_balance_currency` (`currency_id`),
  CONSTRAINT `aiu_fk_balance_account` FOREIGN KEY (`username_id`) REFERENCES `aiu_account` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `aiu_fk_balance_currency` FOREIGN KEY (`currency_id`) REFERENCES `aiu_currency` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

@pavog
Copy link
Owner

pavog commented Oct 22, 2019

Ah now I get it.
The initial column definition " + WORLD_NAME_FIELD + " varchar(255)," (from here) does not add a not null / not nullable condition. But when you create a primary key with this column it makes the column not nullable automagically.

From MySQL Reference:

PRIMARY KEY

A unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. The name of a PRIMARY KEY is always PRIMARY, which thus cannot be used as the name for any other kind of index.

Unfortunately I cannot change the primary key in order to remove the world name from it.

I think the best solution would be to somehow determine the world name of the world the town is in and use it in this function.

I need to dig deeper into this and may need a few days to fix this.
Thanks for you patience.

@TKwSni
Copy link
Author

TKwSni commented Dec 30, 2020

@pavog Hello, I just noticed this, is there a build with this fix working? I want to test

@pavog
Copy link
Owner

pavog commented Mar 22, 2021

@pavog Hello, I just noticed this, is there a build with this fix working? I want to test

Hi, I released a new version today. Can you test it? See here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants