Nothing Special   »   [go: up one dir, main page]

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

🐛 Bug: External database table with constraints/validations fails when inserting a new row - the draft row should be retained. #9569

Open
1 task done
pandigita opened this issue Sep 30, 2024 · 2 comments
Labels
🐛 Type: Bug Something is broken or incorrect unexpectedly.

Comments

@pandigita
Copy link

Please confirm that the bug report does not already exist

  • I confirm there is no existing issue for this bug.

Steps to reproduce

I just installed nocodb as a enduser friendly tool for my staff to navigate my data. Entering a row that had an sql validation error led to the row being lost (after navigating to a different view).
Sadly this makes nocodb completely unusable for non-technical users, I don't really see the difference to just using any database tool.
The sql validation error was also not displayed in a user friendly way. Just use AI to translate all sql errors to non-technical language once.

Desired Behavior

  1. UI needs to clearly display when row has not been submitted (e.g. highlight in red)
  2. row needs to be saved as draft, at the very least in the browser store or something (but probably in a separate DB)
  3. sql validation errors need to be non-technical user readable

Project Details

Node: v20.15.1
Arch: x64
Platform: linux
Docker: true
RootDB: sqlite3
PackageVersion: 0.255.2

Attachments

No response

Copy link
dosubot bot commented Sep 30, 2024

Hey @pandigita! I'm here to help you with any bugs, questions, or contributions you have for the project. Let's work together to solve this issue!

To address the issues raised:

  1. UI Display for Unsubmitted Rows:

    • Implement a mechanism to highlight rows with validation errors in the UI. This can be achieved by adding a visual indicator (e.g., red highlight) to rows that have not been successfully submitted.
  2. Saving Draft Rows:

    • Implement client-side storage (e.g., using browser storage) to save draft rows. This ensures that data is not lost even if the user navigates away from the current view. Alternatively, consider saving drafts in a separate database table.
  3. User-Friendly SQL Validation Errors:

    • Utilize the extractDBError function from the catchError.ts file to extract and format database errors into readable messages. This function can help translate technical SQL errors into non-technical, user-friendly language [1].

Here is an example of how you can handle SQL validation errors and display them in a user-friendly manner:

import { extractDBError } from 'path/to/catchError';
import { NcErrorType } from 'nocodb-sdk';

async function handleDatabaseOperation() {
  try {
    // Your database operation here
  } catch (error) {
    const dbError = extractDBError(error);
    if (dbError) {
      console.error(dbError.message);
      // Display the error message to the user in a user-friendly way
      // For example, you can send this message as a response in an API
      return {
        error: NcErrorType.DATABASE_ERROR,
        message: dbError.message,
        details: dbError.details,
      };
    } else {
      // Handle other types of errors
      console.error('An unknown error occurred');
      return {
        error: NcErrorType.UNKNOWN_ERROR,
        message: 'An unknown error occurred',
      };
    }
  }
}

Additionally, you can leverage NocoDB's BaseModelSqlv2 class to handle and display validation errors effectively [2].

Implementing these changes should help make NocoDB more user-friendly and prevent data loss due to validation errors.

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the 🐛 Type: Bug Something is broken or incorrect unexpectedly. label Sep 30, 2024
@o1lab
Copy link
Member
o1lab commented Sep 30, 2024

For now, work around is to use new record by form option for this case.
image

.
.

And we are going to soon introduce this feature in the grid where data entry for non-standard tables will be possible via only form. Also we are looking at how best to do this at grid as well.

@o1lab o1lab changed the title 🐛 Bug: whole row is lost if it didn't meet validation 🐛 Bug: External database table with constraints/validations fails when inserting a new row - the draft row should be retained. Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something is broken or incorrect unexpectedly.
Projects
Status: 🏌️ Open
Development

No branches or pull requests

2 participants