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

Primary key icon #108

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/packages/cli/src/cli/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const execAsync = promisify(exec)
beforeAll(async () => {
await execAsync('rm -rf ./dist-cli/ ./node_modules/.tmp')
await execAsync('pnpm run build')
}, 20000 /* 20 seconds for setup */)
}, 30000 /* 30 seconds for setup */)

describe('CLI Smoke Test', () => {
it('should run the CLI command without errors', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ exports[`parse > should parse schema.rb to JSON correctly 1`] = `
"increment": false,
"name": "id",
"notNull": false,
"primary": false,
"primary": true,
"type": "varchar",
"unique": false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const convertToDBStructure = (data: any): DBStructure => {
increment: false,
name: field.name,
notNull: 'nullable' in field ? !field.nullable : false,
primary: false,
primary: field.PK || false,
type: field.type.type_name,
unique: false,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe(processor, () => {
users: aTable({
name: 'users',
columns: {
id: aColumn(),
id: aColumn({ primary: true }),
...override?.columns,
},
}),
Expand All @@ -27,7 +27,7 @@ describe(processor, () => {

const expected = userTable({
columns: {
id: aColumn(),
id: aColumn({ primary: true }),
name: aColumn({
name: 'name',
type: 'string',
Expand All @@ -48,7 +48,7 @@ describe(processor, () => {

const expected = userTable({
columns: {
id: aColumn(),
id: aColumn({ primary: true }),
name: aColumn({
name: 'name',
type: 'string',
Expand All @@ -69,7 +69,7 @@ describe(processor, () => {

const expected = userTable({
columns: {
id: aColumn(),
id: aColumn({ primary: true }),
name: aColumn({
name: 'name',
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2318,7 +2318,8 @@ function peg$parse(input, options) {
if (!idField) {
table.fields.unshift({
name: "id",
type: { type_name: "varchar" }
type: { type_name: "varchar" },
PK: true,
Comment on lines -2321 to +2322
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: src/parser/postgres have already primary-key handling logic.

});
}
data.tables.push(table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
if (!idField) {
table.fields.unshift({
name: "id",
type: { type_name: "varchar" }
type: { type_name: "varchar" },
PK: true,
});
}
data.tables.push(table);
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/erd-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@biomejs/biome": "1.9.3",
"@liam/configs": "workspace:*",
"@liam/db-structure": "workspace:*",
"@liam/ui": "workspace:*",
"@types/react": "18",
"typed-css-modules": "0.9.1",
"typescript": "5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Table } from '@liam/db-structure'
import { KeyRound } from '@liam/ui'
import type { Node, NodeProps } from '@xyflow/react'
import type { FC } from 'react'
import styles from './TableNode.module.css'
Expand All @@ -18,6 +19,17 @@ export const TableNode: FC<Props> = ({ data: { table } }) => {
<ul>
{Object.values(table.columns).map((column) => (
<li key={column.name}>
<span>
{column.primary && (
<KeyRound
width={16}
height={16}
role="img"
aria-label="Primary Key"
/>
)}
</span>
<span> </span>
<span>{column.name}</span>
<span> </span>
<span>{column.type}</span>
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/ui/src/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './InfoIcon'
export * from './XIcon'
export * from './FacebookIcon'
export * from './LinkedInIcon'
export { KeyRound } from 'lucide-react'
3 changes: 3 additions & 0 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.