Skip to content

Quite simple method is marked as too complex to analyze #95

Open

Description

@unv-unv

изображение

public class SQLClob
{
    protected static final int MAX_STRING_LITERAL_LENGTH = 3904;

    public final String value;

    public SQLClob(String value)
    {
        this.value = value;
    }

//    @SuppressWarnings("ConstantConditions")
    public void appendTo(StringBuilder sql)
    {
        if (value == null)
        {
            sql.append("to_clob(null)");
            return;
        }
        else if (value.isEmpty())
        {
            sql.append("empty_clob()");
            return;
        }

        for (int i = 0, j, n = value.length(); i < n; i = j)
        {
            if (i > 0) sql.append(" ||");
            j = Math.min(i + MAX_STRING_LITERAL_LENGTH, n);
            sql.append("to_clob('")
                .append(value.substring(i, j).replace("'", "''"))
                .append("')");
        }
    }
}

Activity

  1. self-assigned this
    on Oct 22, 2021
  2. VISTALL commented on Oct 22, 2021

    @VISTALL
    Member

    simplified

    public class SQLClob
    {
        public void appendTo(String sql)
        {
    
            for (int i = 0, j, n = sql.length(); i < n; i = j)
            {
                j = Math.min(i + 5, n);
            }
        }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions