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

mysql 字段的默认值columnDefaultValue 一直是null,导致创建表的时候没有吧默认值带过来 #428

Open
Harries opened this issue Nov 26, 2024 · 0 comments

Comments

@Harries
Copy link

Harries commented Nov 26, 2024

package io.tapdata.common;

import io.tapdata.entity.schema.TapField;
import io.tapdata.entity.utils.DataMap;

/**
 * attributes for common columns
 *
 * @author Jarad
 * @date 2022/4/20
 */
public class CommonColumn {

    protected String columnName;
    protected String dataType;
    protected String nullable;
    protected String remarks;
    protected String columnDefaultValue;
    protected String autoInc;
    protected String pureDataType;
    protected Integer dataLength;
    protected Integer dataPrecision;
    protected Integer dataScale;

    public CommonColumn() {
    }

    public CommonColumn(DataMap dataMap) {
        this.columnName = dataMap.getString("columnName");
        this.dataType = dataMap.getString("dataType");
        this.pureDataType = dataMap.getString("dataType");
        this.dataLength = dataMap.getInteger("dataLength");
        this.dataPrecision = dataMap.getInteger("dataPrecision");
        this.dataScale = dataMap.getInteger("dataScale");
        this.nullable = dataMap.getString("nullable");
        this.remarks = dataMap.getString("columnComment");
        this.columnDefaultValue = null;
    }

    protected Boolean isNullable() {
        return "1".equals(this.nullable);
    }

    protected Boolean isAutoInc() {
        return "1".equals(this.autoInc);
    }

    public TapField getTapField() {
        return new TapField(this.columnName, this.dataType).nullable(this.isNullable()).
                defaultValue(columnDefaultValue).comment(this.remarks);
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant