Code

Opened 5 years ago

Closed 5 years ago

#10114 closed (invalid)

spaces are inserted for 'blank' fields

Reported by: wmstudio Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description (last modified by ramiro)

I have a model in which several fields are specified as follows:

    lat_dec = models.FloatField(blank=True, null=True)
    lon_dec = models.FloatField(blank=True, null=True)
    lat_dms = models.CharField(max_length=9, blank=True, null=True)
    lon_dms = models.CharField(max_length=10, blank=True, null=True)

In case of the CharFields, spaces are inserted into the database (PostgreSQL) when in the admin form the entry-fields are left blank. I found that out because I made some trigger procedures which update lat_dec and lon_dec when lat_dms and lon_dms (see model) are specified and vice versa. Now I made a workaround by adjusting the trigger procedure so it sets the fields to NULL when containing only spaces.

Attachments (0)

Change History (2)

comment:1 Changed 5 years ago by ramiro

  • Description modified (diff)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

(reformatted description)

Do these values stored in the database really contain space(s)? How many of them? Or are they empty strings?

comment:2 Changed 5 years ago by jacob

  • Resolution set to invalid
  • Status changed from new to closed

The admin strips leading and trailing spaces, so I don't quite see how this would be happening, and sure enough I can't reproduce this. Please investigate further to make sure it's not a bug in your own code, and reopen if you can provide more details to help us track this down.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.