ENUM dropdowns?

ENUM dropdowns?

Postby EcoReality » Wed Feb 15, 2017 5:24 pm

I have a MySQL data model with a number of ENUM types, like "Yes, No" or "kilograms, grams, pounds, ounces" or "hectare, acre, square feet, linear feet", etc.

Is there an easy way to suck these in, or must I manually duplicate them and keep them in sync?

Thanks!
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
 
Posts: 26
Joined: Wed Feb 15, 2017 5:20 pm
Location: Salt Spring Island, British Columbia, Canada

Re: ENUM dropdowns?

Postby EcoReality » Thu Feb 16, 2017 12:33 pm

Okay, I got this far. I defined my dropdown with the following SQL, which puts each ENUM value on a separate line. I have tested this in phpMyAdmin.

Code: Select all
SELECT REPLACE(REPLACE(REPLACE(COLUMN_TYPE, 'enum(''', ''), ''')', ''), ''',''', '\n')
FROM (SELECT COLUMN_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'SSIAA'
AND TABLE_NAME = 'Questionares'
AND COLUMN_NAME = 'Role') x


But when I look at the generated form, the dropdown simply has "undefined" on it.

Do I need to do something else to make it look more like each ENUM value is a separate row, which is what I'm guessing nuBuilder is wanting?
Attachments
Screenshot  2017-02-15 at 19.01.17.png
Screenshot 2017-02-15 at 19.01.17.png (18.93 KiB) Viewed 3170 times
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
 
Posts: 26
Joined: Wed Feb 15, 2017 5:20 pm
Location: Salt Spring Island, British Columbia, Canada

Re: ENUM dropdowns?

Postby EcoReality » Fri Feb 17, 2017 9:59 am

BUMP!

After looking at literal string examples, I changed the code below so that the ENUM values have vertical bars around them, and tested it in phpMyAdmin. Still no joy.

Help! I've got DOZENS of these, and I really don't want to maintain them separately, let alone copy/paste/edit them all!

It seems to me this would be a commonly used thing. Does no one use ENUMS here?

Thanks in advance for any help offered!
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
 
Posts: 26
Joined: Wed Feb 15, 2017 5:20 pm
Location: Salt Spring Island, British Columbia, Canada

Re: ENUM dropdowns?

Postby admin » Mon Feb 20, 2017 6:54 am

Jan,

I never have.

Steven
admin
Site Admin
 
Posts: 3348
Joined: Mon Jun 15, 2009 9:53 am

Re: ENUM dropdowns?

Postby EcoReality » Mon Feb 20, 2017 8:05 am

admin wrote:I never have.


I recommend them for shortish string lists that are unlikely to change. They save complications of external lookup tables for trivial stuff like "Yes/No" items, while leaving the database human-readable in tools like phpMyAdmin. They save time, space, and accuracy over storing strings for things like "Pounds/Kilograms" (or was it "Kilogrammes?" OR "kilograms?")

Downside: no i18n multi-language capability, although you can still key the native ENUM strings into a dictionary of other languages.

I would like to "feature request" this for v4: that you add a new object type "ENUM" that automagically detects ENUM types, creates a drop-down for them, and sets its default value to the SQL default value.

If you can give me a starting point to where to do such a change, I might be able to do it for you.

Your competition (not really!) vFront has them. Here is an example field definition in their form builder:
Attachments
Screenshot  2017-02-19 at 14.30.04.png
Screenshot 2017-02-19 at 14.30.04.png (23.3 KiB) Viewed 3152 times
:::: Jan Steinman EcoReality Co-op ::::
EcoReality
 
Posts: 26
Joined: Wed Feb 15, 2017 5:20 pm
Location: Salt Spring Island, British Columbia, Canada

Re: ENUM dropdowns?

Postby admin » Tue Feb 21, 2017 6:16 am

Jan,

Lists like this can be created in version 3 and will do the same in 4.

http://wiki.nubuilder.net/nubuilderv3/index.php/Adding_Objects#Listbox_Tab

Sorry but we have no plans for anything else.

Steven
admin
Site Admin
 
Posts: 3348
Joined: Mon Jun 15, 2009 9:53 am


Return to General